“Styled Components Requisiten TypeScript” Code-Antworten

Styled Components Requisiten TypeScript

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

# NPM
npm install @types/styled-components
Salo Hopeless

Styled Component Typscript

//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)};
    `;
Shirshak kandel

Ähnliche Antworten wie “Styled Components Requisiten TypeScript”

Fragen ähnlich wie “Styled Components Requisiten TypeScript”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen