Stylenames
A simple JavaScript utility for conditionally joining react native styles together.
npm:
npm install rn-stylenames --save
Yarn:
yarn add rn-stylenames
Usage
The stylenames
function takes any number of arguments which can be a number, plain object or array.
The argument 51
is short for { 51: true }
.
If the value associated with a given key is falsy, that key won't be included in the output.
If the given key is not style object id, it will be passed as common key:value pair.
If the given value is array, it will be recursively walked through.
; // => [51, 52]; // => [51, 52]; // => [51, {fontSize: 18}]; // => [51, {fontSize: 18}]
Usage with React Native
;;; const styles = StyleSheet; const Screen = { const textStyles = ; return <View> <Text style=textStyles>Hello World!</Text> </View> ;}
License
MIT. Copyright (c) 2018 Anton Bebnev.