JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/prop-types@15.5.10/prop-types.js"></script>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="container"></div>
CSS
chooseContain: {
margin: 5,
flexDirection:"row",
justifyContent:"space-between",
}
,
chooseItem: {
backgroundColor: '#226977',
borderWidth:3,
borderColor:'#757575',
width:100,
height:30,
alignItems:'center',
margin:5,
borderRadius:5,
}
,
chooseItem1: {
backgroundColor: '#757575',
width:100,
alignItems:'center',
height:30,
margin:5,
borderRadius:5,
}
,
chooseItemF: {
width: 100,
height:30,
margin:5,
}
,
choosetxt: {
fontSize: 15,
color:'white',
textAlign:'center',
textAlignVertical:'center',
}
,
chooseItem_loo: {
backgroundColor: '#226977',
width:85,
height:30,
alignItems:'center',
margin:5,
borderRadius:5,
}
,
chooseItem_loo1: {
backgroundColor: '#757575',
width:85,
alignItems:'center',
height:30,
margin:5,
borderRadius:5,
}
Babel + JSX
class App extends React.Component {
static propTypes = {
name: PropTypes.string,
};
render() {
return (
<View style={styles.body}>
<View style={styles.sectionContainer1}>
<View style={styles.chooseContain}>
<TouchableOpacity onPress={() =>this.setState({stateExample:'Good'})}>
<View style={this.state.stateExample=='Good styles.chooseItem:styles.chooseItem1'}>
<Text style={styles.choosetxt}>Good</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={()=>this.setState({stateExample:'Bad'})}>
<View style={this.state.stateExample =='Bad' ? styles.chooseItem:styles.chooseItem1}>
<Text style={styles.choosetxt}>Bad</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={()=>this.setState({stateExample:'Poor'})}>
<View style={this.state.stateExample=='Poor' ? styles.chooseItem:styles.chooseItem1}>
<Text style={styles.choosetxt}>Poor</Text>
</View>
</TouchableOpacity>
</View>
</View>
</View>
);
}
}
ReactDOM.render(<App name="world"/>, document.getElementById('container'));