Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show text (YES/NO) inside a switch in react-native

Tags:

react-native

I am new to react-native. In my app, I'm using a switch and changing the tint color to differentiate ON and OFF, but my actual requirement is to show "YES" or "NO" text inside the switch like below.

enter image description here

Here is my Code:

<Switch
                    onValueChange={this.change.bind(this)}
                    style={{marginBottom:10,width:90,marginRight:6,marginLeft:6}}
                    value={true}
                    thumbTintColor="#0000ff"
                    tintColor="#ff0000"
                    />

Please give me suggestions to solve this issue, Any help much appreciated.

like image 941
Lavaraju Avatar asked Nov 29 '16 12:11

Lavaraju


1 Answers

Finally I got the On off inside switch .......

install

npm install --save react-native-switch

    import { Switch } from 'react-native-switch';

<Switch
value={true}
onValueChange={(val) => console.log(val)}
disabled={false}
activeText={'On'}
inActiveText={'Off'}
backgroundActive={'green'}
backgroundInactive={'gray'}
circleActiveColor={'#30a566'}
circleInActiveColor={'#000000'}/>

Refer this link... https://github.com/shahen94/react-native-switch

like image 107
Lavaraju Avatar answered Sep 29 '22 08:09

Lavaraju