ClassNames for React Native
This library resolve styles merging in react-native
Like package classNames
for regular React
Install
Step one:
npm i classnames-react-native
Step two:
Enjoy!
API
classnames([styleObject][, [styleObject, conditions]])
Examples
Example #1
const A = padding: 10 const B = backgroudColor: '#fff' const C = margin: 10 // classNames(styleObject, [styleObject, conditions], [styleObject, conditions]) /* classNames returns this styles: */ padding: 10 // from object A backgroudColor: "#fff" // from object B (conditions is positive) // object C is ignored (because conditions is negative)
Example #2
{ const wide = true ghost = false } = thisprops const style = /* * classnames returns object, witch includes styles: * - spacing * - root * - wide * - fill */ return <View style=style> ... </View> }