Skip to content

felixmc/react-combine-styles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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} />
    )
  }
  
}

About

conditionally combine react native styles

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published