quest answer
quest answer

Reputation: 95

How to change background colour transparent in React-Native checkBox?

In my scenario, I am trying to implement react native check box for android and iOS using Reactnative Elements. Here, I need to change checkbox with label background colour. It is showing full white but how to change it is transparent?

https://react-native-elements.github.io/react-native-elements/docs/checkbox.html

<CheckBox
  checkedIcon={<Image source={require('../checked.png')} />}
  uncheckedIcon={<Image source={require('../unchecked.png')} />}
  checked={this.state.checked}
  onPress={() => this.setState({checked: !this.state.checked})}
/>

Upvotes: 2

Views: 4399

Answers (1)

user2675468
user2675468

Reputation: 145

Just use the containerStyle prop (https://react-native-elements.github.io/react-native-elements/docs/checkbox.html#containerstyle) The easiest (but also ugliest) way would be to say

<CheckBox
  containerStyle ={{backgroundColor: 'transparent'}}
  checkedIcon={<Image source={require('../checked.png')} />}
  uncheckedIcon={<Image source={require('../unchecked.png')} />}
  checked={this.state.checked}
  onPress={() => this.setState({checked: !this.state.checked})}
/>

Upvotes: 4

Related Questions