react-native-simple-radio-button-input

1.0.4 • Public • Published

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

React Native Radio Button

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


Readme

Keywords

none

Package Sidebar

Install

npm i react-native-simple-radio-button-input

Weekly Downloads

11

Version

1.0.4

License

MIT

Unpacked Size

3.29 kB

Total Files

4

Last publish

Collaborators

  • arshidkv12