Skip to content

Instantly share code, notes, and snippets.

@wickedst
Created November 8, 2021 20:32
Show Gist options
  • Select an option

  • Save wickedst/fab4fb0f6ed925efd6590b95e56ff709 to your computer and use it in GitHub Desktop.

Select an option

Save wickedst/fab4fb0f6ed925efd6590b95e56ff709 to your computer and use it in GitHub Desktop.
Styled-components React TS example
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