Skip to content

Instantly share code, notes, and snippets.

@streamich
Created October 7, 2017 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save streamich/a14bc9eaa9ad7a4674ae0d7d84e743d4 to your computer and use it in GitHub Desktop.
Save streamich/a14bc9eaa9ad7a4674ae0d7d84e743d4 to your computer and use it in GitHub Desktop.
Dynamic CSS for React components using React's v16 element array render result
class Button extends Component {
@css`
background-color: #ff0000;
width: 320px;
padding: 20px;
border-radius: 5px;
border: none;
outline: none;
&:hover {
color: #fff;
}
&:active {
position: relative;
top: 2px;
}
@media (max-width: 480px) {
& {
width: 160px;
}
}
`;
render() {
return <button>{this.props.children}</button>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment