Answers for "theming in styled components with typescript"

5

styled components props typescript

# to prevent typescript error, install this
yarn add @types/styled-components

# NPM
npm install @types/styled-components
Posted by: Guest on July-14-2020
6

styled-components error in typescript

//in styled component with param define type of param
const StyledComponent = styled.div`
        background: black;
        color: white;
    `;

    const StyledComponentWithParams = styled.div<{ color?: string }>`
        background: yellow;
        color: ${(color) => (color ? "yellow" : "white")};
    `;

    const StyledComponentDefaultValueParams = styled.div<{ color?: string }>`
        background: yellow;
        color: ${(color = "white") => (color)};
    `;
Posted by: Guest on November-05-2021

Code answers related to "theming in styled components with typescript"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language