1.0.2 • Published 8 years ago

react-combine-styles v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

React Combine Styles

A simple javascript utility for conditionally combining react native styles.

Inspired by the classnames npm module found here.

Install

npm install react-combine-styles

Usage

Compatible with both ES5 and ES6

import { StyleSheet } from 'react-native'
import combineStyles from 'react-combine-styles'

const styles = StyleSheet.create({
  textInput: {
     ...
  },
  disabledTextInput: {
     ...
  },
  focussedTextInput: {
     ...
  },
})

...

class FancyTextInput extends Component {

  render() {
    const textStyles = combineStyles({
      textInput: true,
      disabledTextInput: this.props.isDisabled,
      focussedTextInput: this.props.isFocussed
    }, styles)
   
    return (
      <TexInput style={textStyles} />
    )
  }
  
}