Skip to content

Instantly share code, notes, and snippets.

@itsMapleLeaf
Last active December 25, 2017 09:45
Show Gist options
  • Save itsMapleLeaf/d02e59889e3055548003f000502322ff to your computer and use it in GitHub Desktop.
Save itsMapleLeaf/d02e59889e3055548003f000502322ff to your computer and use it in GitHub Desktop.
My preferred way of doing style overrides in styled-components
const Button = styled.button`
border: 1px solid black;
${props => props.primary && primaryStyle};
${props => props.danger && dangerStyle};
${props => props.warning && warningStyle};
`
const primaryStyle = css`
color: white;
background: blue;
`
const dangerStyle = css`
color: white;
background: red;
`
const warningStyle = css`
color: white;
background: yellow;
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment