Skip to content

Instantly share code, notes, and snippets.

@opensourcekam
Created April 21, 2019 20:37
Show Gist options
  • Save opensourcekam/1e9819a0fc83ababdbcd03a99ebf32e1 to your computer and use it in GitHub Desktop.
Save opensourcekam/1e9819a0fc83ababdbcd03a99ebf32e1 to your computer and use it in GitHub Desktop.
How to type a styled component
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