Gathering detailed insights and metrics for react-native-picker-select
Gathering detailed insights and metrics for react-native-picker-select
Gathering detailed insights and metrics for react-native-picker-select
Gathering detailed insights and metrics for react-native-picker-select
🔽 A Picker component for React Native which emulates the native <select> interfaces for iOS and Android
npm install react-native-picker-select
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,765 Stars
311 Commits
499 Forks
21 Watching
5 Branches
50 Contributors
Updated on 27 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-10.1%
22,035
Compared to previous day
Last week
3.7%
120,168
Compared to previous week
Last month
9.2%
511,361
Compared to previous month
Last year
28.6%
5,011,774
Compared to previous year
2
1
26
A Picker component for React Native which emulates the native <select>
interfaces for iOS and Android
For iOS, by default we are wrapping an unstyled TextInput component. You can then pass down styles to customize it to your needs.
For Android, by default we are using the native Picker component. If you prefer, you can set useNativeAndroidPickerStyle
to false, which will also render an unstyled TextInput component. You can then pass down styles to customize it to your needs.
For either platform, you can alternatively pass down a child element of your choice that will be wrapped in a touchable area.
This package is built around and depends on @react-native-picker/picker. Please make sure you install it correctly (as seen below in installation steps).
1npm install react-native-picker-select 2 3# React Native users 4npm install @react-native-picker/picker 5npx pod-install 6 7# Expo 8expo install @react-native-picker/picker
1import RNPickerSelect from 'react-native-picker-select'; 2 3export const Dropdown = () => { 4 return ( 5 <RNPickerSelect 6 onValueChange={(value) => console.log(value)} 7 items={[ 8 { label: 'Football', value: 'football' }, 9 { label: 'Baseball', value: 'baseball' }, 10 { label: 'Hockey', value: 'hockey' }, 11 ]} 12 /> 13 ); 14};
Version | Notes |
---|---|
>=Â 8.0.0 | Uses @react-native-picker/picker. React Native 0.60 or above. If using Expo, SDK38 or above. |
>=Â 3.0.0 | React v16.3 or above. |
<Â 3.0.0 | React v16.2 or below. |
Name | Description | Details |
---|---|---|
onValueChange | Callback which returns value, index | required function |
items | The items for the component to render - Each item should be in the following format: {label: 'Orange', value: 'orange', key: 'orange', color: 'orange', inputLabel: 'Orange!', testID: 'e2e-orange'} - label and value are required- key , color , testID , and inputLabel are optional- key will be set to equal label if not included- value can be any data type- If inputLabel exists, the TextInput will display that value instead of the label | required array |
placeholder | - An override for the default placeholder object with a label of Select an item... and a value of null - An empty object can be used if you'd like to disable the placeholder entirely | object |
disabled | Disables interaction with the component | boolean |
value | Will attempt to locate a matching item from the items array by checking each item's value property. If found, it will update the component to show that item as selected. If the value is not found, it will default to the first item. WARNING: do not use this attribute on iOS if you plan to allow the user to modify the value from within the Picker , use itemKey instead. | any |
itemKey | Will attempt to locate a matching item from the items array by checking each item's key property. If found, it will update the component to show that item as selected. If the key is not found, it will attempt to find a matching item by value as above. | string, number |
style | Style overrides for most parts of the component. More details in styling | object |
darkTheme iOS only | Use the dark theme for the Picker. | boolean |
pickerProps | Additional props to pass to the Picker (some props are used in core functionality so use this carefully) | object |
Icon | Custom icon component to be rendered. More details in styling | Component |
textInputProps | Additional props to pass to the TextInput (some props are used in core functionality so use this carefully). This is iOS only unless useNativeAndroidPickerStyle={false} . | object |
touchableWrapperProps | Additional props to pass to the touchable wrapping the TextInput (some props are used in core functionality so use this carefully) | object |
onOpen() | Callback triggered right before the opening of the picker Not supported when useNativeAndroidPickerStyle={true} | function |
useNativeAndroidPickerStyle Android only | The component defaults to using the native Android Picker in its un-selected state. Setting this flag to false will mimic the default iOS presentation where a tappable TextInput is displayed.More details in styling | boolean |
fixAndroidTouchableBug Android only | Experimental flag to fix issue #354 | boolean |
InputAccessoryView iOS only | Replace the InputAcessoryView section (bar with tabbing arrown and Done button) of the opened picker with your own custom component. Can also return null here to hide completely. While this bar is typical on select elements on the web, the interface guidelines does not include it. View the snack to see examples on how this can be customized. | Component |
doneText iOS only | "Done" default text on the modal. Can be overwritten here | string |
onUpArrow() / onDownArrow() iOS only | Presence enables the corresponding arrow - Closes the picker - Calls the callback provided | function |
onDonePress() iOS only | Callback when the 'Done' button is pressed | function |
onClose(Bool) iOS only | Callback triggered right before the closing of the picker. It has one boolean parameter indicating if the done button was pressed or not | function |
modalProps iOS only | Additional props to pass to the Modal (some props are used in core functionality so use this carefully) | object |
touchableDoneProps iOS only | Additional props to pass to the Done touchable (some props are used in core functionality so use this carefully) | object |
All properties mentioned below must be nested under the style
prop. Examples of different styling options can be found on the example snack.
inputIOS
.inputIOSContainer
, placeholder
, viewContainer
, chevronContainer
, chevron
, chevronUp
, chevronDown
, chevronActive
, done
, modalViewTop
, modalViewMiddle
, and modalViewBottom
inputAndroid
.useNativeAndroidPickerStyle
to false, the component will allow a few other style objects: inputAndroidContainer
, placeholder
, and inputAndroid
headlessAndroidContainer
and viewContainer
inputWeb
Icon
prop - it will be rendered with { position: 'absolute', right: 0 }
applied to its wrapping container. You can modify these values and add additional spacing to position the icon as needed by modifying iconContainer
. You'll probably also want to add some paddingRight
to your input styling to avoid any longer text appearing behind the icon.If you need to add accessibility props to the rendered component, you may use pickerProps
and touchableWrapperProps
to pass these through.
pickerProps
accepts an object of props that get passed directly to the native <Picker />
component.
touchableWrapperProps
also accepts an object of props, but this gets passed to a <TouchableOpacity />
that toggles the visibility of the picker.*note: touchableWrapperProps
is not supported on web or when useNativeAndroidPickerStyle={true}
In the example below, we render the picker with supplementary description text, but for screen readers, we omit this by passing just the title to the accessibilityLabel
prop.
1const selectedItem = { 2 title: 'Selected item title', 3 description: 'Secondary long descriptive text ...', 4}; 5 6export const Dropdown = () => { 7 return ( 8 <RNPickerSelect 9 pickerProps={{ 10 accessibilityLabel: selectedItem.title, 11 }} 12 > 13 <Text>{selectedItem.title}</Text> 14 <Text>{selectedItem.description}</Text> 15 </RNPickerSelect> 16 ); 17};
Test suite included. This component has been used and tested since React Native v0.51.
react-native-picker-select is MIT licensed and built with :heart: in Austin, TX by the team at LawnStarter
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
17 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
51 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morereact-native-image-crop-picker
Select single or multiple images, with cropping option
react-native-image-picker
A React Native module that allows you to use native UI to select media from the device library or directly from the camera
@react-native-picker/picker
React Native Picker for iOS, Android, macOS, and Windows
react-native-modal-datetime-picker
A react-native datetime-picker for Android and iOS