Created
April 21, 2019 20:37
-
-
Save opensourcekam/1e9819a0fc83ababdbcd03a99ebf32e1 to your computer and use it in GitHub Desktop.
How to type a styled component
This file contains 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, { StyledFunction } from "styled-components" | |
interface YourProps { | |
invalid: boolean | |
} | |
const input: StyledFunction<YourProps & React.HTMLProps<HTMLInputElement>> = styled.input | |
const Input = input` | |
border: ${p => p.invalid ? 'red' : 'blue'}; | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment