How to create React Native Picker with text and icon

In this React Native source code example, the source code below illustrate how to create React Native Picker with text and icon.

You can copy and adopt this source code example to your React Native project without reinventing the wheel.

import React, { Component } from 'react';
import { View, StyleSheet,Text,Picker} from 'react-native'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';

export default class App extends Component {

   render() {
      return (
        <View style={styles.container}>
          <View style={{width:'60%',flexDirection: 'row',justifyContent: 'center', backgroundColor: 'white',paddingVertical: 10}}>
            <Picker mode="dropdown" style={{ height:20, backgroundColor: 'white',width: '80%'}}>
              <Picker.Item label="Option1" value="option1" />
              <Picker.Item label="Option2" value="option2" />
              <Picker.Item label="Option3" value="option3" />
            </Picker>
            <Icon name="chevron-down-circle" size={25} style= {{color:"rgb(21, 212, 63)" }} />
          </View>
        </View>
      );
   }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#ddd'
  },
});

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.

 

Add a Comment