A customizable dropdown selection package for react-native for android and iOS with multiple select and search capabilities.
npm install react-native-input-select
   

A fully customizable dropdown selection package for react-native android and iOS with multiple select and search capabilities.
With npm
``sh`
npm install react-native-input-select
With yarn
`sh`
yarn add react-native-input-select
See more examples in Sandbox
| | | |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| |
|
|
| |
|
|
| | | |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| |
|
|
Starting from recent versions of React Native, certain safe area utilities have been deprecated, which may cause layout issues or warnings if not configured properly.
To ensure consistent behavior across devices (especially on iOS with notches and status bars), you must wrap your root component with SafeAreaProvider from react-native-safe-area-context.
β Example Setup
`js
import { SafeAreaProvider } from 'react-native-safe-area-context';
import App from './App';
export default function Root() {
return (
);
}
`
`js
import React from 'react';
import Dropdown from 'react-native-input-select';
export default function App() {
const [country, setCountry] = React.useState();
return (
placeholder="Select an option..."
options={[
{ label: 'Nigeria', value: 'NG' },
{ label: 'Γ
land Islands', value: 'AX' },
{ label: 'Algeria', value: 'DZ' },
{ label: 'American Samoa', value: 'AS' },
{ label: 'Andorra', value: 'AD' },
]}
selectedValue={country}
onValueChange={(value) => setCountry(value)}
primaryColor={'green'}
/>
);
}
`
`js
import React from 'react';
import Dropdown from 'react-native-input-select';
import { View, StyleSheet, Text, Button, Alert, Image } from 'react-native';
export default function App() {
const [country, setCountry] = React.useState();
return (
placeholder="Select multiple countries..."
options={countries.slice(0, 30)}
optionLabel={'name'}
optionValue={'code'}
selectedValue={country}
onValueChange={(itemValue: any) => setCountry(itemValue)}
isMultiple
isSearchable
primaryColor={'orange'}
dropdownStyle={{
borderWidth: 0, // To remove border, set borderWidth to 0
}}
dropdownIcon={
source={{
uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg==',
}}
/>
}
dropdownIconStyle={{ top: 20, right: 20 }}
listHeaderComponent={
π‘ You can add any component to the top of this list
title="Left button"
onPress={() => Alert.alert('Left button pressed')}
color="#007AFF"
/>
title="Right button"
onPress={() => Alert.alert('Right button pressed')}
/>
}
listFooterComponent={
}
modalControls={{
modalOptionsContainerStyle: {
padding: 10,
backgroundColor: 'cyan',
},
modalProps: {
supportedOrientations: [
'portrait',
'portrait-upside-down',
'landscape',
'landscape-left',
'landscape-right',
],
transparent: false,
},
}}
listComponentStyles={{
listEmptyComponentStyle: {
color: 'red',
},
itemSeparatorStyle: {
opacity: 0,
borderColor: 'white',
borderWidth: 2,
backgroundColor: 'cyan',
},
sectionHeaderStyle: {
padding: 10,
backgroundColor: 'cyan',
},
}}
listControls={{
selectAllText: 'Choose everything',
unselectAllText: 'Remove everything',
selectAllCallback: () => Alert.alert('You selected everything'),
unselectAllCallback: () => Alert.alert('You removed everything'),
emptyListMessage: 'No record found',
}}
selectedItemsControls={{
removeItemIcon: (
uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA',
}}
style={{ tintColor: 'white', height: 12, width: 12 }}
/>
),
onRemoveItem: () => Alert.alert('Item was removed'),
showRemoveIcon: true,
}}
/>
);
}
const styles = StyleSheet.create({
customComponentContainer: {
paddingHorizontal: 20,
paddingVertical: 10,
},
text: {
marginBottom: 20,
},
fixToText: {
flexDirection: 'row',
justifyContent: 'space-between',
},
tinyLogo: {
width: 20,
height: 20,
},
radioButton: {
width: 20,
height: 20,
borderRadius: 20 / 2,
borderWidth: 3,
borderColor: 'white',
},
});
`
`js`
placeholder="Select multiple dishes..."
options={[
{
title: 'Main dishes',
data: [
{ label: 'Pizza', value: 'A' },
{ label: 'Burger', value: 'B' },
{ label: 'Risotto', value: 'C' },
],
},
{
title: 'Sides',
data: [
{ label: 'Ice cream', value: 'D' },
{ label: 'Cheesecake', value: 'E' },
],
},
{
title: 'Drinks',
data: [
{ label: 'Water', value: 'F' },
{ label: 'Coke', value: 'G' },
{ label: 'Juice', value: 'H' },
],
},
]}
selectedValue={menu}
onValueChange={(itemValue: any) => setMenu(itemValue)}
isMultiple
isSearchable
primaryColor={'deepskyblue'}
listComponentStyles={{
sectionHeaderStyle: {
padding: 10,
backgroundColor: 'green',
color: 'white',
width: '30%',
},
}}
/>
For more examples visit our wiki page
| Proptypes | Datatype | Example |
| ------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| label | string or ReactComponent | Countries or |string
| placeholder | | Select a country |Array
| options | | [{ name: 'Nigeria', code: 'NG' }, { name: 'Albania', code: 'AL' }] |string
| optionLabel | | name |string
| optionValue | | code |string
| error | | This is a requiredfield |string
| helperText | | Only few countries are listed |string
| selectedValue | or Array | AL or [AL, AX] |function
| onValueChange | | ()=>{} |Boolean
| isMultiple | | true |Boolean
| isSearchable | | true |Boolean
| disabled | | true |React Component
| dropdownIcon | | Image or |Object
| labelStyle | | {color: 'red', fontSize: 15, fontWeight: '500'} |Object
| placeholderStyle | | {color: 'blue', fontSize: 15, fontWeight: '500'} |Object
| dropdownStyle | | {borderColor: 'blue', margin: 5, borderWidth:0 ...} |Object
| dropdownContainerStyle | | {backgroundColor: 'red', width: '30%', ...} |Object
| dropdownIconStyle | | {top: 10 , right: 10, ...} |Object
| selectedItemStyle | | {fontWeight: '600', color: 'yellow', ...} |Object
| multipleSelectedItemStyle | | {backgroundColor: 'red', color: 'yellow', ...} |Object
| dropdownErrorStyle | | {borderWidth: 2, borderStyle: 'solid'} |Object
| dropdownErrorTextStyle | | {color: 'red', fontWeight:'500'} |Object
| dropdownHelperTextStyle | | {color: 'green', fontWeight:'500'} |string
| primaryColor | | blue |boolean
| autoCloseOnSelect | | false |React Component
| listHeaderComponent | | |React Component
| listFooterComponent | | |Object
| listComponentStyles | | {listEmptyComponentStyle: ViewStyle, itemSeparatorStyle: ViewStyle, sectionHeaderStyle: TextStyle} |React Component
| listEmptyComponent | | |Object
| checkboxControls | | {checkboxSize: number, checkboxStyle: ViewStyle, checkboxLabelStyle: TextStyle, checkboxComponent?: React.ReactNode, checkboxDisabledStyle?: ViewStyle, checkboxUnselectedColor?: ColorValue} |Object
| listControls | | { selectAllText: 'Choose all', unselectAllText: 'Remove all', selectAllCallback: () => {}, unselectAllCallback: () => {}, hideSelectAll: boolean, emptyListMessage: 'No record found', keyboardShouldPersistTaps: "always" } |Object
| searchControls | | { textInputStyle: ViewStyle \| TextStyle, textInputContainerStyle: ViewStyle, textInputProps: TextInputProps, searchCallback:(value)=>{}} |Object
| modalControls | | { modalBackgroundStyle: ViewStyle, modalOptionsContainerStyle: ViewStyle, modalProps: ModalProps} |number
| minSelectableItems | | 3 |number
| maxSelectableItems | | 5 |Object
| selectedItemsControls | | { removeItemIcon: ReactNode, onRemoveItem: ()=>{}, showRemoveIcon: boolean} |useRef
| ref |
See the contributing guide to learn how to contribute to the repository and the development workflow.
Made with contrib.rocks.
For discussion and feedback on this library. You can access it by heading over to the Discussions Tab on Github. We've created some sections to keep the discussion focused.
| Title | Topic |
| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| Announcements π£ | General announcements about this library. |
| Show and tell π | Show off something you've made out of this library |
| Ideas π‘ | A place to Share ideas for new features. |
| Polls π³οΈ | Take a vote from the community |
| Q&A π€ | A place to ask the community for help on the New Architecture topics |
| General π¬ | Chat about anything and everything here |
MIT
https://github.com/azeezat/react-native-select/assets/9849221/194bf5cf-1a2d-4ca6-9585-05d6bb987aba