react-native-radio-buttons-group
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "react-native-radio-buttons-group", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Simple and Best. An easy to use radio buttons for react native apps.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
107
README.md
# React Native Radio Buttons Group | ||
Simple and Best. An easy to use radio buttons for react native apps. | ||
## Getting Started | ||
### Installation | ||
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. | ||
``` | ||
npm i react-native-radio-buttons-group --save | ||
``` | ||
### Installing | ||
### Getting Started | ||
###### App.js | ||
``` | ||
npm i react-native-radio-buttons-group --save | ||
import React, { Component } from 'react'; | ||
import { Text, View, StyleSheet } from 'react-native'; | ||
import RadioGroup from 'react-native-radio-buttons-group'; | ||
export default class App extends Component { | ||
state = { | ||
// Below mention objects explains different props supported by radio button | ||
radioButtons: [ | ||
{}, // empty object will create radio button with default values | ||
{ | ||
label: 'Selected', | ||
selected: true, | ||
}, | ||
{ | ||
label: 'With just a label', | ||
}, | ||
{ | ||
label: 'Value is different', | ||
value: "I'm not same as label", | ||
}, | ||
{ | ||
label: 'Color', | ||
color: 'green', | ||
}, | ||
{ | ||
disabled: true, | ||
label: 'Disabled', | ||
}, | ||
{ | ||
label: 'Size', | ||
size: 32, | ||
}, | ||
{ | ||
label: 'Layout column', | ||
layout: 'column', | ||
}, | ||
], | ||
}; | ||
// update state | ||
onPress = radioButtons => this.setState({ radioButtons }); | ||
// output | ||
onSubmit = () => { | ||
const selectedButton = this.state.radioButtons.find(e => e.selected == true).value; | ||
alert(selectedButton); | ||
}; | ||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<RadioGroup | ||
radioButtons={this.state.radioButtons} | ||
onPress={this.onPress} | ||
/> | ||
<Text style={styles.submit} onPress={this.onSubmit}>Submit</Text> | ||
</View> | ||
); | ||
} | ||
} | ||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
submit: { | ||
borderWidth: 1, | ||
borderRadius: 4, | ||
paddingHorizontal: 100, | ||
paddingVertical: 10, | ||
}, | ||
}); | ||
``` | ||
### Default | ||
### Default object of radio button | ||
``` | ||
@@ -29,12 +107,15 @@ { | ||
``` | ||
color | ||
disabled | ||
label | ||
layout | ||
selected | ||
size | ||
value | ||
Props Data Type Valid Values | ||
----------------------------------------------------- | ||
color String < all css formats > | ||
disabled Boolean true/false | ||
label String | ||
layout String row/column | ||
selected Boolen true/false | ||
size Number < positive numbers > | ||
value String < mention value if you want to give different value other than 'label'> | ||
``` | ||
### TODO | ||
- animation | ||
@@ -48,2 +129,2 @@ | ||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details | ||
This project is licensed under the [MIT License](https://github.com/ThakurBallary/react-native-radio-buttons-group/blob/master/LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8263
129