Skip to content

Instantly share code, notes, and snippets.

@chrislloyd
Created October 19, 2016 16:48
Show Gist options
  • Save chrislloyd/472fd5a44d2ae12815ac16bffe28fc4b to your computer and use it in GitHub Desktop.
Save chrislloyd/472fd5a44d2ae12815ac16bffe28fc4b to your computer and use it in GitHub Desktop.
// 1. Second dynamic argument — first is "guarenteed" to not interpolate
const Button = styled.button(`
/* Adapt the colors based on primary prop */
font-size: 1em;
margin: 1em;
padding: 0.25em 1em;
border: 2px solid palevioletred;
border-radius: 3px;
`, (props) => `
background: ${window.innerWidth < 1000 ? 'palevioletred' : 'white'};
color: ${window.innerWidth < 1000 ? 'white' : 'palevioletred'};
`);
// 2. Explicit static opt-in, throws errors when dynamic props are used, and styles are extracted
const Button = styled.static.button(`
/* Adapt the colors based on primary prop */
font-size: 1em;
margin: 1em;
padding: 0.25em 1em;
border: 2px solid palevioletred;
border-radius: 3px;
background: transparent;
color: #efefef;
`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment