react-native-simple-radio-button-input
v1.0.4
Published
simple radio button component for React Native
Downloads
27
Readme
React Native Simple Radio Button
How to install ?
npm i react-native-simple-radio-button-input
or
yarn add react-native-simple-radio-button-input
Example
import RadioButton from 'react-native-simple-radio-button-input';
<RadioButton
color={'red'}
selected={true}
onPress={()=>{})}
/>
Complete Example
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import RadioButton from 'react-native-simple-radio-button-input';
const DATA = ['Student', 'Teacher'];
export default class index extends Component {
constructor(props) {
super(props);
this.state = {
selected:null
};
}
render() {
return (
<View style={{flex:1, justifyContent:'center', padding:15}}>
{DATA.map(val=>(
<View style={{flexDirection:'row', marginBottom:15, alignItems:'center'}}>
<RadioButton
color={'blue'}
selected={this.state.selected==val}
onPress={()=>{this.setState({
selected: val
})
}}
/>
<Text style={{marginLeft:7}}> {val} </Text>
</View>
))}
</View>
);
}
}