Created
November 8, 2021 20:32
-
-
Save wickedst/fab4fb0f6ed925efd6590b95e56ff709 to your computer and use it in GitHub Desktop.
Styled-components React TS example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import styled from "styled-components"; | |
| interface TitleProps { | |
| isActive: boolean; | |
| } | |
| export const Title = ({ isActive }: TitleProps) => { | |
| return ( | |
| <TitleContainer isActive={isActive} id="dashboard-title"> | |
| <h1>Dashboard</h1> | |
| <h2>Welcome to your portal</h2> | |
| </TitleContainer> | |
| ); | |
| }; | |
| const TitleContainer = styled.div<TitleProps>` | |
| h1 { | |
| color: ${props => (props.isActive ? "black" : "grey")}; | |
| font-family: var(--font-heading); | |
| font-weight: 400; | |
| margin-bottom: 0.1rem; | |
| } | |
| h2 { | |
| margin: 0; | |
| font-weight: 300; | |
| } | |
| `; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment