Gathering detailed insights and metrics for @pirles/react-native-element-dropdown
Gathering detailed insights and metrics for @pirles/react-native-element-dropdown
Gathering detailed insights and metrics for @pirles/react-native-element-dropdown
Gathering detailed insights and metrics for @pirles/react-native-element-dropdown
A react-native dropdown component easy to customize for both iOS and Android.
npm install @pirles/react-native-element-dropdown
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (97.21%)
JavaScript (2.79%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
343 Commits
1 Branches
1 Contributors
Updated on Mar 23, 2025
Latest Version
2.15.0
Package Id
@pirles/react-native-element-dropdown@2.15.0
Unpacked Size
359.21 kB
Size
60.98 kB
File Count
121
NPM Version
10.9.2
Node Version
23.10.0
Published on
Mar 23, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
23
React Native Element Dropdown is a library that provides a customizable dropdown component for React Native applications. This library simplifies the process of creating dropdown menus and provides a variety of options to customize the dropdown to match the design and functionality of your application.
1If you love this library, give us a star, you will be a ray of sunshine in our lives :)
React Native Template with a beautiful UI.
1npm install react-native-element-dropdown --save
or
1yarn add react-native-element-dropdown
Props | Params | isRequire | Description |
---|---|---|---|
mode | 'default' or 'modal' of 'auto' | No | Mode 'modal' is show the dropdown in the middle of the screen. |
data | Array | Yes | Data is a plain array |
labelField | String | Yes | Extract the label from the data item |
valueField | String | Yes | Extract the primary key from the data item |
searchField | String | No | Specify the field of data list you want to search |
onChange | (item: object) => void | Yes | Selection callback |
onChangeText | (search: string) => void | No | Callback that is called when the text input's text changes |
value | Item | No | Set default value |
placeholder | String | No | The string that will be rendered before dropdown has been selected |
placeholderStyle | TextStyle | No | Styling for text placeholder |
selectedTextStyle | TextStyle | No | Styling for selected text |
selectedTextProps | TextProps | No | Text Props for selected text. Ex: numberOfLines={1} |
style | ViewStyle | No | Styling for view container |
containerStyle | ViewStyle | No | Styling for list container |
maxHeight | Number | No | Customize max height for list container |
minHeight | Number | No | Customize min height for list container |
fontFamily | String | No | Customize font style |
iconStyle | ImageStyle | No | Styling for icon |
iconColor | String | No | Color of icons |
itemContainerStyle | TextStyle | No | Styling for item container in list |
itemTextStyle | TextStyle | No | Styling for text item in list |
activeColor | String | No | Background color for item selected in list container |
search | Boolean | No | Show or hide input search |
searchQuery | (keyword: string, labelValue: string) => Boolean | No | Callback used to filter the list of items |
inputSearchStyle | ViewStyle | No | Styling for input search |
searchPlaceholder | String | No | The string that will be rendered before text input has been entered |
searchPlaceholderTextColor | String | No | The text color of the placeholder string |
renderInputSearch | (onSearch: (text:string) => void) => JSX.Element | No | Customize TextInput search |
disable | Boolean | No | Specifies the disabled state of the Dropdown |
dropdownPosition | 'auto' or 'top' or 'bottom' | No | Dropdown list position. Default is 'auto' |
autoScroll | Boolean | No | Auto scroll to index item selected, default is true |
showsVerticalScrollIndicator | Boolean | No | When true, shows a vertical scroll indicator, default is true |
renderLeftIcon | (visible?: boolean) => JSX.Element | No | Customize left icon for dropdown |
renderRightIcon | (visible?: boolean) => JSX.Element | No | Customize right icon for dropdown |
renderItem | (item: object, selected: Boolean) => JSX.Element | No | Takes an item from data and renders it into the list |
flatListProps | FlatListProps | No | Customize FlatList element |
inverted | Boolean | No | Reverses the direction of scroll on top position mode. Default is true |
onFocus | () => void | No | Callback that is called when the dropdown is focused |
onBlur | () => void | No | Callback that is called when the dropdown is blurred |
keyboardAvoiding | Boolean | No | keyboardAvoiding default is true |
backgroundColor | String | No | Set background color |
confirmSelectItem | Boolean | No | Turn On confirm select item. Refer example/src/dropdown/example3 |
onConfirmSelectItem | (item: object) => void | No | Selection callback. Refer example/src/dropdown/example3 |
testID | String | No | Used to locate this view in end-to-end tests |
itemTestIDField | String | No | Add this field to the input data. Ex: DATA = [{itemTestIDField: '', label: '', value:: ''}] |
accessibilityLabel | String | No | Set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected |
itemAccessibilityLabelField | String | No | Add this field to the input data. Ex: DATA = [{itemAccessibilityLabelField: '', label: '', value:: ''}] |
closeModalWhenSelectedItem | Boolean | No | By default, closeModalWhenSelectedItem is set to true. When closeModalWhenSelectedItem is set to false, the Modal won't close when an item is selected. |
excludeItems | Item[] | No | The array containing the items to be excluded. |
excludeSearchItems | Item[] | No | The array containing the items to be excluded. |
Props | Params | isRequire | Description |
---|---|---|---|
mode | 'default' or 'modal' of 'auto' | No | Mode 'modal' is show the dropdown in the middle of the screen. |
data | Array | Yes | Data is a plain array |
labelField | String | Yes | Extract the label from the data item |
valueField | String | Yes | Extract the primary key from the data item |
searchField | String | No | Specify the field of data list you want to search |
onChange | (value[]) => void | Yes | Selection callback. A array containing the "valueField". |
onChangeText | (search: string) => void | No | Callback that is called when the text input's text changes |
value | Item[] | No | Set default value. A array containing the "valueField". |
placeholder | String | No | The string that will be rendered before dropdown has been selected |
placeholderStyle | TextStyle | No | Styling for text placeholder |
style | ViewStyle | No | Styling for view container |
containerStyle | ViewStyle | No | Styling for list container |
maxHeight | Number | No | Customize max height for list container |
minHeight | Number | No | Customize min height for list container |
maxSelect | Number | No | maximum number of items that can be selected |
fontFamily | String | No | Customize font style |
iconStyle | ImageStyle | No | Styling for icon |
iconColor | String | No | Color of icons |
activeColor | String | No | Background color for item selected in list container |
itemContainerStyle | TextStyle | No | Styling for item container in list |
itemTextStyle | TextStyle | No | Styling for text item in list |
selectedStyle | ViewStyle | No | Styling for selected view |
selectedTextStyle | TextStyle | No | Styling for selected text |
selectedTextProps | TextProps | No | Text Props for selected text. Ex: numberOfLines={1} |
renderSelectedItem | (item: object, unSelect?: () => void) => JSX.Element | No | Takes an item from data and renders it into the list selected |
alwaysRenderSelectedItem | Boolean | No | Always show the list of selected items |
visibleSelectedItem | Boolean | No | Option to hide selected item list, Ẽx: visibleSelectedItem={false} |
search | Boolean | No | Show or hide input search |
searchQuery | (keyword: string, labelValue: string) => Boolean | No | Callback used to filter the list of items |
inputSearchStyle | ViewStyle | No | Styling for input search |
searchPlaceholder | String | No | The string that will be rendered before text input has been entered |
searchPlaceholderTextColor | String | No | The text color of the placeholder string |
renderInputSearch | (onSearch: (text:string) => void) => JSX.Element | No | Customize TextInput search |
disable | Boolean | No | Specifies the disabled state of the Dropdown |
dropdownPosition | 'auto' or 'top' or 'bottom' | No | Dropdown list position. Default is 'auto' |
showsVerticalScrollIndicator | Boolean | No | When true, shows a vertical scroll indicator, default is true |
renderLeftIcon | (visible?: boolean) => JSX.Element | No | Customize left icon for dropdown |
renderRightIcon | (visible?: boolean) => JSX.Element | No | Customize right icon for dropdown |
renderItem | (item: object, selected: Boolean) => JSX.Element | No | Takes an item from data and renders it into the list |
flatListProps | FlatListProps | No | Customize FlatList element |
inverted | Boolean | No | Reverses the direction of scroll on top position mode. Default is true |
onFocus | () => void | No | Callback that is called when the dropdown is focused |
onBlur | () => void | No | Callback that is called when the dropdown is blurred |
keyboardAvoiding | Boolean | No | keyboardAvoiding default is true |
inside | Boolean | No | inside default is false |
backgroundColor | String | No | Set background color |
confirmSelectItem | Boolean | No | Turn On confirm select item. Refer example/src/dropdown/example7 |
confirmUnSelectItem | Boolean | No | Turn On confirm un-select item. Refer example/src/dropdown/example7 |
onConfirmSelectItem | (item: any) => void | No | Selection callback. Refer example/src/dropdown/example7 |
testID | String | No | Used to locate this view in end-to-end tests |
itemTestIDField | String | No | Add this field to the input data. Ex: DATA = [{itemTestIDField: '', label: '', value:: ''}] |
accessibilityLabel | String | No | Set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected |
itemAccessibilityLabelField | String | No | Add this field to the input data. Ex: DATA = [{itemAccessibilityLabelField: '', label: '', value:: ''}] |
excludeItems | Item[] | No | The array containing the items to be excluded. |
excludeSearchItems | Item[] | No | The array containing the items to be excluded. |
Props | Params | isRequire | Description |
---|---|---|---|
imageField | String | Yes | Extract the image from the data item |
imageStyle | ImageStyle | No | Styling for image |
API | Params | Description |
---|---|---|
open | () => void | Open dropdown list |
close | () => void | Close dropdown list |
1 import React, { useState } from 'react'; 2 import { StyleSheet, Text, View } from 'react-native'; 3 import { Dropdown } from 'react-native-element-dropdown'; 4 import AntDesign from '@expo/vector-icons/AntDesign'; 5 6 const data = [ 7 { label: 'Item 1', value: '1' }, 8 { label: 'Item 2', value: '2' }, 9 { label: 'Item 3', value: '3' }, 10 { label: 'Item 4', value: '4' }, 11 { label: 'Item 5', value: '5' }, 12 { label: 'Item 6', value: '6' }, 13 { label: 'Item 7', value: '7' }, 14 { label: 'Item 8', value: '8' }, 15 ]; 16 17 const DropdownComponent = () => { 18 const [value, setValue] = useState(null); 19 const [isFocus, setIsFocus] = useState(false); 20 21 const renderLabel = () => { 22 if (value || isFocus) { 23 return ( 24 <Text style={[styles.label, isFocus && { color: 'blue' }]}> 25 Dropdown label 26 </Text> 27 ); 28 } 29 return null; 30 }; 31 32 return ( 33 <View style={styles.container}> 34 {renderLabel()} 35 <Dropdown 36 style={[styles.dropdown, isFocus && { borderColor: 'blue' }]} 37 placeholderStyle={styles.placeholderStyle} 38 selectedTextStyle={styles.selectedTextStyle} 39 inputSearchStyle={styles.inputSearchStyle} 40 iconStyle={styles.iconStyle} 41 data={data} 42 search 43 maxHeight={300} 44 labelField="label" 45 valueField="value" 46 placeholder={!isFocus ? 'Select item' : '...'} 47 searchPlaceholder="Search..." 48 value={value} 49 onFocus={() => setIsFocus(true)} 50 onBlur={() => setIsFocus(false)} 51 onChange={item => { 52 setValue(item.value); 53 setIsFocus(false); 54 }} 55 renderLeftIcon={() => ( 56 <AntDesign 57 style={styles.icon} 58 color={isFocus ? 'blue' : 'black'} 59 name="Safety" 60 size={20} 61 /> 62 )} 63 /> 64 </View> 65 ); 66 }; 67 68 export default DropdownComponent; 69 70 const styles = StyleSheet.create({ 71 container: { 72 backgroundColor: 'white', 73 padding: 16, 74 }, 75 dropdown: { 76 height: 50, 77 borderColor: 'gray', 78 borderWidth: 0.5, 79 borderRadius: 8, 80 paddingHorizontal: 8, 81 }, 82 icon: { 83 marginRight: 5, 84 }, 85 label: { 86 position: 'absolute', 87 backgroundColor: 'white', 88 left: 22, 89 top: 8, 90 zIndex: 999, 91 paddingHorizontal: 8, 92 fontSize: 14, 93 }, 94 placeholderStyle: { 95 fontSize: 16, 96 }, 97 selectedTextStyle: { 98 fontSize: 16, 99 }, 100 iconStyle: { 101 width: 20, 102 height: 20, 103 }, 104 inputSearchStyle: { 105 height: 40, 106 fontSize: 16, 107 }, 108 });
1 import React, { useState } from 'react'; 2 import { StyleSheet } from 'react-native'; 3 import { Dropdown } from 'react-native-element-dropdown'; 4 import AntDesign from '@expo/vector-icons/AntDesign'; 5 6 const data = [ 7 { label: 'Item 1', value: '1' }, 8 { label: 'Item 2', value: '2' }, 9 { label: 'Item 3', value: '3' }, 10 { label: 'Item 4', value: '4' }, 11 { label: 'Item 5', value: '5' }, 12 { label: 'Item 6', value: '6' }, 13 { label: 'Item 7', value: '7' }, 14 { label: 'Item 8', value: '8' }, 15 ]; 16 17 const DropdownComponent = () => { 18 const [value, setValue] = useState(null); 19 20 return ( 21 <Dropdown 22 style={styles.dropdown} 23 placeholderStyle={styles.placeholderStyle} 24 selectedTextStyle={styles.selectedTextStyle} 25 inputSearchStyle={styles.inputSearchStyle} 26 iconStyle={styles.iconStyle} 27 data={data} 28 search 29 maxHeight={300} 30 labelField="label" 31 valueField="value" 32 placeholder="Select item" 33 searchPlaceholder="Search..." 34 value={value} 35 onChange={item => { 36 setValue(item.value); 37 }} 38 renderLeftIcon={() => ( 39 <AntDesign style={styles.icon} color="black" name="Safety" size={20} /> 40 )} 41 /> 42 ); 43 }; 44 45 export default DropdownComponent; 46 47 const styles = StyleSheet.create({ 48 dropdown: { 49 margin: 16, 50 height: 50, 51 borderBottomColor: 'gray', 52 borderBottomWidth: 0.5, 53 }, 54 icon: { 55 marginRight: 5, 56 }, 57 placeholderStyle: { 58 fontSize: 16, 59 }, 60 selectedTextStyle: { 61 fontSize: 16, 62 }, 63 iconStyle: { 64 width: 20, 65 height: 20, 66 }, 67 inputSearchStyle: { 68 height: 40, 69 fontSize: 16, 70 }, 71 });
1 import React, { useState } from 'react'; 2 import { StyleSheet, View, Text } from 'react-native'; 3 import { Dropdown } from 'react-native-element-dropdown'; 4 import AntDesign from '@expo/vector-icons/AntDesign'; 5 6 const data = [ 7 { label: 'Item 1', value: '1' }, 8 { label: 'Item 2', value: '2' }, 9 { label: 'Item 3', value: '3' }, 10 { label: 'Item 4', value: '4' }, 11 { label: 'Item 5', value: '5' }, 12 { label: 'Item 6', value: '6' }, 13 { label: 'Item 7', value: '7' }, 14 { label: 'Item 8', value: '8' }, 15 ]; 16 17 const DropdownComponent = () => { 18 const [value, setValue] = useState(null); 19 20 const renderItem = item => { 21 return ( 22 <View style={styles.item}> 23 <Text style={styles.textItem}>{item.label}</Text> 24 {item.value === value && ( 25 <AntDesign 26 style={styles.icon} 27 color="black" 28 name="Safety" 29 size={20} 30 /> 31 )} 32 </View> 33 ); 34 }; 35 36 return ( 37 <Dropdown 38 style={styles.dropdown} 39 placeholderStyle={styles.placeholderStyle} 40 selectedTextStyle={styles.selectedTextStyle} 41 inputSearchStyle={styles.inputSearchStyle} 42 iconStyle={styles.iconStyle} 43 data={data} 44 search 45 maxHeight={300} 46 labelField="label" 47 valueField="value" 48 placeholder="Select item" 49 searchPlaceholder="Search..." 50 value={value} 51 onChange={item => { 52 setValue(item.value); 53 }} 54 renderLeftIcon={() => ( 55 <AntDesign style={styles.icon} color="black" name="Safety" size={20} /> 56 )} 57 renderItem={renderItem} 58 /> 59 ); 60 }; 61 62 export default DropdownComponent; 63 64 const styles = StyleSheet.create({ 65 dropdown: { 66 margin: 16, 67 height: 50, 68 backgroundColor: 'white', 69 borderRadius: 12, 70 padding: 12, 71 shadowColor: '#000', 72 shadowOffset: { 73 width: 0, 74 height: 1, 75 }, 76 shadowOpacity: 0.2, 77 shadowRadius: 1.41, 78 79 elevation: 2, 80 }, 81 icon: { 82 marginRight: 5, 83 }, 84 item: { 85 padding: 17, 86 flexDirection: 'row', 87 justifyContent: 'space-between', 88 alignItems: 'center', 89 }, 90 textItem: { 91 flex: 1, 92 fontSize: 16, 93 }, 94 placeholderStyle: { 95 fontSize: 16, 96 }, 97 selectedTextStyle: { 98 fontSize: 16, 99 }, 100 iconStyle: { 101 width: 20, 102 height: 20, 103 }, 104 inputSearchStyle: { 105 height: 40, 106 fontSize: 16, 107 }, 108 });
1 import React, { useState } from 'react'; 2 import { StyleSheet, View } from 'react-native'; 3 import { MultiSelect } from 'react-native-element-dropdown'; 4 import AntDesign from '@expo/vector-icons/AntDesign'; 5 6 const data = [ 7 { label: 'Item 1', value: '1' }, 8 { label: 'Item 2', value: '2' }, 9 { label: 'Item 3', value: '3' }, 10 { label: 'Item 4', value: '4' }, 11 { label: 'Item 5', value: '5' }, 12 { label: 'Item 6', value: '6' }, 13 { label: 'Item 7', value: '7' }, 14 { label: 'Item 8', value: '8' }, 15 ]; 16 17 const MultiSelectComponent = () => { 18 const [selected, setSelected] = useState([]); 19 20 return ( 21 <View style={styles.container}> 22 <MultiSelect 23 style={styles.dropdown} 24 placeholderStyle={styles.placeholderStyle} 25 selectedTextStyle={styles.selectedTextStyle} 26 inputSearchStyle={styles.inputSearchStyle} 27 iconStyle={styles.iconStyle} 28 search 29 data={data} 30 labelField="label" 31 valueField="value" 32 placeholder="Select item" 33 searchPlaceholder="Search..." 34 value={selected} 35 onChange={item => { 36 setSelected(item); 37 }} 38 renderLeftIcon={() => ( 39 <AntDesign 40 style={styles.icon} 41 color="black" 42 name="Safety" 43 size={20} 44 /> 45 )} 46 selectedStyle={styles.selectedStyle} 47 /> 48 </View> 49 ); 50 }; 51 52 export default MultiSelectComponent; 53 54 const styles = StyleSheet.create({ 55 container: { padding: 16 }, 56 dropdown: { 57 height: 50, 58 backgroundColor: 'transparent', 59 borderBottomColor: 'gray', 60 borderBottomWidth: 0.5, 61 }, 62 placeholderStyle: { 63 fontSize: 16, 64 }, 65 selectedTextStyle: { 66 fontSize: 14, 67 }, 68 iconStyle: { 69 width: 20, 70 height: 20, 71 }, 72 inputSearchStyle: { 73 height: 40, 74 fontSize: 16, 75 }, 76 icon: { 77 marginRight: 5, 78 }, 79 selectedStyle: { 80 borderRadius: 12, 81 }, 82 });
1 import React, { useState } from 'react'; 2 import { StyleSheet, View, TouchableOpacity, Text } from 'react-native'; 3 import { MultiSelect } from 'react-native-element-dropdown'; 4 import AntDesign from '@expo/vector-icons/AntDesign'; 5 6 const data = [ 7 { label: 'Item 1', value: '1' }, 8 { label: 'Item 2', value: '2' }, 9 { label: 'Item 3', value: '3' }, 10 { label: 'Item 4', value: '4' }, 11 { label: 'Item 5', value: '5' }, 12 { label: 'Item 6', value: '6' }, 13 { label: 'Item 7', value: '7' }, 14 { label: 'Item 8', value: '8' }, 15 ]; 16 17 const MultiSelectComponent = () => { 18 const [selected, setSelected] = useState([]); 19 20 const renderItem = item => { 21 return ( 22 <View style={styles.item}> 23 <Text style={styles.selectedTextStyle}>{item.label}</Text> 24 <AntDesign style={styles.icon} color="black" name="Safety" size={20} /> 25 </View> 26 ); 27 }; 28 29 return ( 30 <View style={styles.container}> 31 <MultiSelect 32 style={styles.dropdown} 33 placeholderStyle={styles.placeholderStyle} 34 selectedTextStyle={styles.selectedTextStyle} 35 inputSearchStyle={styles.inputSearchStyle} 36 iconStyle={styles.iconStyle} 37 data={data} 38 labelField="label" 39 valueField="value" 40 placeholder="Select item" 41 value={selected} 42 search 43 searchPlaceholder="Search..." 44 onChange={item => { 45 setSelected(item); 46 }} 47 renderLeftIcon={() => ( 48 <AntDesign 49 style={styles.icon} 50 color="black" 51 name="Safety" 52 size={20} 53 /> 54 )} 55 renderItem={renderItem} 56 renderSelectedItem={(item, unSelect) => ( 57 <TouchableOpacity onPress={() => unSelect && unSelect(item)}> 58 <View style={styles.selectedStyle}> 59 <Text style={styles.textSelectedStyle}>{item.label}</Text> 60 <AntDesign color="black" name="delete" size={17} /> 61 </View> 62 </TouchableOpacity> 63 )} 64 /> 65 </View> 66 ); 67 }; 68 69 export default MultiSelectComponent; 70 71 const styles = StyleSheet.create({ 72 container: { padding: 16 }, 73 dropdown: { 74 height: 50, 75 backgroundColor: 'white', 76 borderRadius: 12, 77 padding: 12, 78 shadowColor: '#000', 79 shadowOffset: { 80 width: 0, 81 height: 1, 82 }, 83 shadowOpacity: 0.2, 84 shadowRadius: 1.41, 85 86 elevation: 2, 87 }, 88 placeholderStyle: { 89 fontSize: 16, 90 }, 91 selectedTextStyle: { 92 fontSize: 14, 93 }, 94 iconStyle: { 95 width: 20, 96 height: 20, 97 }, 98 inputSearchStyle: { 99 height: 40, 100 fontSize: 16, 101 }, 102 icon: { 103 marginRight: 5, 104 }, 105 item: { 106 padding: 17, 107 flexDirection: 'row', 108 justifyContent: 'space-between', 109 alignItems: 'center', 110 }, 111 selectedStyle: { 112 flexDirection: 'row', 113 justifyContent: 'center', 114 alignItems: 'center', 115 borderRadius: 14, 116 backgroundColor: 'white', 117 shadowColor: '#000', 118 marginTop: 8, 119 marginRight: 12, 120 paddingHorizontal: 12, 121 paddingVertical: 8, 122 shadowOffset: { 123 width: 0, 124 height: 1, 125 }, 126 shadowOpacity: 0.2, 127 shadowRadius: 1.41, 128 129 elevation: 2, 130 }, 131 textSelectedStyle: { 132 marginRight: 5, 133 fontSize: 16, 134 }, 135 });
1 import React, { useState } from 'react'; 2 import { StyleSheet } from 'react-native'; 3 import { SelectCountry } from 'react-native-element-dropdown'; 4 5 const local_data = [ 6 { 7 value: '1', 8 lable: 'Country 1', 9 image: { 10 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 11 }, 12 }, 13 { 14 value: '2', 15 lable: 'Country 2', 16 image: { 17 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 18 }, 19 }, 20 { 21 value: '3', 22 lable: 'Country 3', 23 image: { 24 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 25 }, 26 }, 27 { 28 value: '4', 29 lable: 'Country 4', 30 image: { 31 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 32 }, 33 }, 34 { 35 value: '5', 36 lable: 'Country 5', 37 image: { 38 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 39 }, 40 }, 41 ]; 42 43 const SelectCountryScreen = _props => { 44 const [country, setCountry] = useState('1'); 45 46 return ( 47 <SelectCountry 48 style={styles.dropdown} 49 selectedTextStyle={styles.selectedTextStyle} 50 placeholderStyle={styles.placeholderStyle} 51 imageStyle={styles.imageStyle} 52 inputSearchStyle={styles.inputSearchStyle} 53 iconStyle={styles.iconStyle} 54 search 55 maxHeight={200} 56 value={country} 57 data={local_data} 58 valueField="value" 59 labelField="lable" 60 imageField="image" 61 placeholder="Select country" 62 searchPlaceholder="Search..." 63 onChange={e => { 64 setCountry(e.value); 65 }} 66 /> 67 ); 68 }; 69 70 export default SelectCountryScreen; 71 72 const styles = StyleSheet.create({ 73 dropdown: { 74 margin: 16, 75 height: 50, 76 borderBottomColor: 'gray', 77 borderBottomWidth: 0.5, 78 }, 79 imageStyle: { 80 width: 24, 81 height: 24, 82 }, 83 placeholderStyle: { 84 fontSize: 16, 85 }, 86 selectedTextStyle: { 87 fontSize: 16, 88 marginLeft: 8, 89 }, 90 iconStyle: { 91 width: 20, 92 height: 20, 93 }, 94 inputSearchStyle: { 95 height: 40, 96 fontSize: 16, 97 }, 98 });
1 import React, { useState } from 'react'; 2 import { StyleSheet } from 'react-native'; 3 import { SelectCountry } from 'react-native-element-dropdown'; 4 5 const local_data = [ 6 { 7 value: '1', 8 lable: 'Country 1', 9 image: { 10 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 11 }, 12 }, 13 { 14 value: '2', 15 lable: 'Country 2', 16 image: { 17 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 18 }, 19 }, 20 { 21 value: '3', 22 lable: 'Country 3', 23 image: { 24 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 25 }, 26 }, 27 { 28 value: '4', 29 lable: 'Country 4', 30 image: { 31 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 32 }, 33 }, 34 { 35 value: '5', 36 lable: 'Country 5', 37 image: { 38 uri: 'https://www.vigcenter.com/public/all/images/default-image.jpg', 39 }, 40 }, 41 ]; 42 43 const SelectCountryScreen = _props => { 44 const [country, setCountry] = useState('1'); 45 46 return ( 47 <SelectCountry 48 style={styles.dropdown} 49 selectedTextStyle={styles.selectedTextStyle} 50 placeholderStyle={styles.placeholderStyle} 51 imageStyle={styles.imageStyle} 52 iconStyle={styles.iconStyle} 53 maxHeight={200} 54 value={country} 55 data={local_data} 56 valueField="value" 57 labelField="lable" 58 imageField="image" 59 placeholder="Select country" 60 searchPlaceholder="Search..." 61 onChange={e => { 62 setCountry(e.value); 63 }} 64 /> 65 ); 66 }; 67 68 export default SelectCountryScreen; 69 70 const styles = StyleSheet.create({ 71 dropdown: { 72 margin: 16, 73 height: 50, 74 width: 150, 75 backgroundColor: '#EEEEEE', 76 borderRadius: 22, 77 paddingHorizontal: 8, 78 }, 79 imageStyle: { 80 width: 24, 81 height: 24, 82 borderRadius: 12, 83 }, 84 placeholderStyle: { 85 fontSize: 16, 86 }, 87 selectedTextStyle: { 88 fontSize: 16, 89 marginLeft: 8, 90 }, 91 iconStyle: { 92 width: 20, 93 height: 20, 94 }, 95 });
No vulnerabilities found.
No security vulnerabilities found.