React Native Element Button Group Example

04-Apr-2023

.

Admin

React Native Element Button Group Example

Hi Guys,

In this blog, I will explain you how to use element button group in react native. You can easily use element button group in react native. First i will create import namespace ButtonGroup from react-native-elements, after I will using element button group using for element button group tagadd in react native example.

Here, I will give you full example for simply display element button group using react native as bellow.

Step 1 - Create project


In the first step Run the following command for create project.

expo init ButtonGroup

Step 2 - Installation of Dependency

In the step, Run the following command for installation of dependency.

To use element button group you need to npm install react-native-elements --save.

To install this open the terminal and jump into your project

cd ButtonGroup

Run the following command

npm install react-native-elements --save

Step 3 - App.js

In this step, You will open App.js file and put the code.

import React from 'react';

import { StyleSheet, Text, View } from 'react-native';

import { ButtonGroup } from 'react-native-elements';

export default function App() {

const buttons = ['INSERT', 'UPDATE', 'DELETE']

return (

<View style={styles.container}>

<ButtonGroup

buttons={buttons}

containerStyle={{height: 40}}

buttonContainerStyle={{backgroundColor: 'cadetblue'}}

textStyle={{color: '#fff'}}

/>

</View>

);

}

const styles = StyleSheet.create({

container: {

flex: 1,

justifyContent: 'center',

},

});

Step 4 - Run project

In the last step run your project using bellow command.

npm start

Output

It will help you...

#React Native