Inline Styles in JS with support for React, Redux, React Native, Autoprefixing, Hover, Pseudo-Elements & Media Queries
npm install reactcss --save
Define a default styles for your elements:
import reactCSS from 'reactcss'
const styles = reactCSS({
'default': {
card: {
background: this.props.background,
boxShadow: '0 2px 4px rgba(0,0,0,.15)',
},
},
})
Pass style definitions via inline styles:
<div style={ styles.card } />
Activate additional classes by passing down objects as additional parameters to reactCSS
:
const styles = reactCSS({
'default': {
card: {
background: '#fff',
boxShadow: '0 2px 4px rgba(0,0,0,.15)',
},
},
'zIndex-2': {
card: {
boxShadow: '0 4px 8px rgba(0,0,0,.15)',
},
},
}, {
'zIndex-2': props.zIndex === 2,
})
See the Full Documentation