How to Create Radio Button Group in React Native?
Published On: 18/06/2022 | Category:
React Native
Hi Guys,
Now, let's see tutorial of how to create radio button group in react native. you'll learn how to use radio button group in react native. This tutorial will give you simple example of react native radio button group example. you can understand a concept of how to implement radio button group in react native. Follow bellow tutorial step of radio button group example in react native.
Let's start following example:
Step 1: Download ProjectIn the first step run the following command to create a project.
expo init ExampleAppStep 2: App.js
In this step, You will open the App.js file and put the code.
import * as React from 'react'; import { View, StyleSheet } from 'react-native'; import { RadioButton, Text } from 'react-native-paper'; const App = () => { const [value, setValue] = React.useState(''); return ( <View style={styles.container}> <RadioButton.Group onValueChange={newValue => setValue(newValue)} value={value}> <View style={styles.innerContainer}> <Text style={styles.categoryTitle}>Select Category:</Text> <View style={styles.radioContainer}> <RadioButton value="React Native" /> <Text style={styles.title}>React Native</Text> </View> <View style={styles.radioContainer}> <RadioButton value="Javascript" /> <Text style={styles.title}>Javascript</Text> </View> <View style={styles.radioContainer}> <RadioButton value="Laravel" /> <Text style={styles.title}>Laravel</Text> </View> <View style={styles.radioContainer}> <RadioButton value="PHP" /> <Text style={styles.title}>PHP</Text> </View> <View style={styles.radioContainer}> <RadioButton value="jQuery" /> <Text style={styles.title}>jQuery</Text> </View> </View> </RadioButton.Group> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor:'#76f6f4', }, innerContainer: { backgroundColor: 'white', padding: 80, shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.8, shadowRadius: 2, elevation: 5, }, radioContainer: { flexDirection: 'row', }, title: { marginTop: 7, }, categoryTitle: { marginBottom:10, fontSize:20, }, }); export default App;Run Project
In the last step run your project using the below command.
expo start
You can QR code scan in Expo Go Application on mobile.
Output :
It will help you...