Picker is a cross-platform UI component for selecting an item from a list of options.
Installations
npm install @react-native-picker/picker
Developer
react-native-picker
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
18.20.5
NPM Version
8.19.4
Statistics
1,532 Stars
463 Commits
291 Forks
16 Watching
21 Branches
131 Contributors
Updated on 27 Nov 2024
Languages
JavaScript (25.63%)
Java (23.96%)
C++ (20.03%)
TypeScript (15.04%)
Objective-C++ (7.09%)
Objective-C (4.52%)
Ruby (1.46%)
Kotlin (1.26%)
CMake (0.83%)
C (0.2%)
Total Downloads
Cumulative downloads
Total Downloads
49,877,515
Last day
-12.2%
82,992
Compared to previous day
Last week
0.8%
443,169
Compared to previous week
Last month
8.9%
1,886,062
Compared to previous month
Last year
30.3%
18,829,989
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
2
Dev Dependencies
32
@react-native-picker/picker
Android | iOS | PickerIOS |
---|---|---|
Windows | MacOS |
---|---|
Supported Versions
@react-native-picker/picker | react-native | react-native-windows |
---|---|---|
>= 2.0.0 | 0.61+ | 0.64+ |
>= 1.16.0 | 0.61+ | 0.61+ |
>= 1.2.0 | 0.60+ or 0.59+ with Jetifier | N/A |
>= 1.0.0 | 0.57 | N/A |
Getting started
$ npm install @react-native-picker/picker --save
or
$ yarn add @react-native-picker/picker
For React Native v0.60 and above (Autolinking)
As react-native@0.60 and above supports autolinking there is no need to run the linking process.
Read more about autolinking here. This is supported by react-native-windows@0.64
and above.
iOS
CocoaPods on iOS needs this extra step:
npx pod-install
Android
No additional step is required.
Windows (expand for details)
Windows
Usage in Windows without autolinking requires the following extra steps:
Add the ReactNativePicker
project to your solution.
- Open the solution in Visual Studio 2019
- Right-click Solution icon in Solution Explorer > Add > Existing Project
Select
D:\dev\RNTest\node_modules\@react-native-picker\picker\windows\ReactNativePicker\ReactNativePicker.vcxproj
windows/myapp.sln
Add a reference to ReactNativePicker
to your main application project. From Visual Studio 2019:
Right-click main application project > Add > Reference...
Check ReactNativePicker
from Solution Projects.
app.cpp
Add #include "winrt/ReactNativePicker.h"
to the headers included at the top of the file.
Add PackageProviders().Append(winrt::ReactNativePicker::ReactPackageProvider());
before InitializeComponent();
.
MacOS
CocoaPods on MacOS needs this extra step (called from the MacOS directory)
pod install
React Native below 0.60 (Link and Manual Installation)
The following steps are only necessary if you are working with a version of React Native lower than 0.60
Mostly automatic installation
$ react-native link @react-native-picker/picker
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
âžœAdd Files to [your project's name]
- Go to
node_modules
➜@react-native-picker/picker
and addRNCPicker.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNCPicker.a
to your project'sBuild Phases
âžœLink Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open application file (
android/app/src/main/java/[...]/MainApplication.java
)
- Add
import com.reactnativecommunity.picker.RNCPickerPackage;
to the imports at the top of the file - Add
new RNCPickerPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':@react-native-picker_picker' project(':@react-native-picker_picker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-picker/picker/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation project(path: ':@react-native-picker_picker')
MacOS
- In XCode, in the project navigator, right click
Libraries
âžœAdd Files to [your project's name]
- Go to
node_modules
➜@react-native-picker/picker
and addRNCPicker.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNCPicker.a
to your project'sBuild Phases
âžœLink Binary With Libraries
- Run your project (
Cmd+R
)<
RTL Support
you need to add android:supportsRtl="true"
to AndroidManifest.xml
1 <application 2 ... 3 android:supportsRtl="true">
Usage
Import Picker from @react-native-picker/picker
:
1import {Picker} from '@react-native-picker/picker';
Create state which will be used by the Picker
:
1const [selectedLanguage, setSelectedLanguage] = useState();
Add Picker
like this:
1<Picker 2 selectedValue={selectedLanguage} 3 onValueChange={(itemValue, itemIndex) => 4 setSelectedLanguage(itemValue) 5 }> 6 <Picker.Item label="Java" value="java" /> 7 <Picker.Item label="JavaScript" value="js" /> 8</Picker>
If you want to open/close picker programmatically on android (available from version 1.16.0+), pass ref to Picker
:
1const pickerRef = useRef(); 2 3function open() { 4 pickerRef.current.focus(); 5} 6 7function close() { 8 pickerRef.current.blur(); 9} 10 11return <Picker 12 ref={pickerRef} 13 selectedValue={selectedLanguage} 14 onValueChange={(itemValue, itemIndex) => 15 setSelectedLanguage(itemValue) 16 }> 17 <Picker.Item label="Java" value="java" /> 18 <Picker.Item label="JavaScript" value="js" /> 19</Picker>
Props
Reference
Props
onValueChange
Callback for when an item is selected. This is called with the following parameters:
itemValue
: thevalue
prop of the item that was selecteditemPosition
: the index of the selected item in this picker
Type | Required |
---|---|
function | No |
selectedValue
Value matching value of one of the items. Can be a string or an integer.
Type | Required |
---|---|
any | No |
style
Type | Required |
---|---|
pickerStyleType | No |
testID
Used to locate this view in end-to-end tests.
Type | Required |
---|---|
string | No |
enabled
If set to false, the picker will be disabled, i.e. the user will not be able to make a selection.
Type | Required | Platform |
---|---|---|
bool | No | Android, Web, Windows |
mode
On Android, specifies how to display the selection items when the user taps on the picker:
- 'dialog': Show a modal dialog. This is the default.
- 'dropdown': Shows a dropdown anchored to the picker view
Type | Required | Platform |
---|---|---|
enum('dialog', 'dropdown') | No | Android |
dropdownIconColor
On Android, specifies color of dropdown triangle. Input value should be value that is accepted by react-native processColor
function.
Type | Required | Platform |
---|---|---|
ColorValue | No | Android |
dropdownIconRippleColor
On Android, specifies ripple color of dropdown triangle. Input value should be value that is accepted by react-native processColor
function.
Type | Required | Platform |
---|---|---|
ColorValue | No | Android |
prompt
Prompt string for this picker, used on Android in dialog mode as the title of the dialog.
Type | Required | Platform |
---|---|---|
string | No | Android |
itemStyle
Style to apply to each of the item labels.
Type | Required | Platform |
---|---|---|
text styles | No | iOS, Windows |
numberOfLines
On Android & iOS, used to truncate the text with an ellipsis after computing the text layout, including line wrapping, such that the total number of lines does not exceed this number. Default is '1'
Type | Required | Platform |
---|---|---|
number | No | Android, iOS |
onBlur
Type | Required | Platform |
---|---|---|
function | No | Android |
onFocus
Type | Required | Platform |
---|---|---|
function | No | Android |
selectionColor
Type | Required | Platform |
---|---|---|
ColorValue | No | iOS |
Methods
blur
(Android only, lib version 1.16.0+)
Programmatically closes picker
focus
(Android only, lib version 1.16.0+)
Programmatically opens picker
PickerItemProps
Props that can be applied to individual Picker.Item
label
Displayed value on the Picker Item
Type | Required |
---|---|
string | Yes |
value
Actual value on the Picker Item
Type | Required |
---|---|
number,string | Yes |
color
Displayed color on the Picker Item
Type | Required |
---|---|
ColorValue | No |
fontFamily
Displayed fontFamily on the Picker Item
Type | Required |
---|---|
string | No |
style
Style to apply to individual item labels.
Type | Required | Platform |
---|---|---|
ViewStyleProp | No | Android |
enabled
If set to false, the specific item will be disabled, i.e. the user will not be able to make a selection
@default: true
Type | Required | Platform |
---|---|---|
boolean | No | Android |
contentDescription
Sets the content description to the Picker Item
Type | Required | Platform |
---|---|---|
string | No | Android |
PickerIOS
Props
Reference
Props
itemStyle
Type | Required |
---|---|
text styles | No |
onValueChange
Type | Required |
---|---|
function | No |
selectedValue
Type | Required |
---|---|
any | No |
selectionColor
Type | Required | Platform |
---|---|---|
ColorValue | No | iOS |
themeVariant
Type | Required |
---|---|
enum('light', 'dark') | No |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
15 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: FabricExample/android/gradle/wrapper/gradle-wrapper.jar:1
- Warn: binary detected: example/android/gradle/wrapper/gradle-wrapper.jar:1
Reason
Found 13/24 approved changesets -- score normalized to 5
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:98: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:105: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:121: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:122: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:128: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:74: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:75: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:78: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:84: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/react-native-picker/picker/publish.yml/master?enable=pin
- Info: 0 out of 22 GitHub-owned GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 21 are checked with a SAST tool
Reason
49 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-2rxp-v6pw-ch6m
- Warn: Project is vulnerable to: GHSA-4xqq-m2hx-25v8
- Warn: Project is vulnerable to: GHSA-5866-49gr-22v4
- Warn: Project is vulnerable to: GHSA-r55c-59qm-vjw6
- Warn: Project is vulnerable to: GHSA-vg3r-rm7w-2xgh
- Warn: Project is vulnerable to: GHSA-vmwr-mc7x-5vc3
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-cr5q-6q9f-rq6q
- Warn: Project is vulnerable to: GHSA-j6gc-792m-qgm2
- Warn: Project is vulnerable to: GHSA-pj73-v5mw-pm9j
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-f5x2-xv93-4p23
- Warn: Project is vulnerable to: GHSA-gmpm-xp43-f7g6
- Warn: Project is vulnerable to: GHSA-pf27-929j-9pmm
- Warn: Project is vulnerable to: GHSA-327c-qx3v-h673
- Warn: Project is vulnerable to: GHSA-x4cf-6jr3-3qvp
- Warn: Project is vulnerable to: GHSA-mph8-6787-r8hw
- Warn: Project is vulnerable to: GHSA-7mhc-prgv-r3q4
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-33f9-j839-rf8h
- Warn: Project is vulnerable to: GHSA-c36v-fmgq-m8hx
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-v8v8-6859-qxm4
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-x565-32qp-m3vf
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-5fg8-2547-mr8q
- Warn: Project is vulnerable to: GHSA-crh6-fp67-6883
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
4.1
/10
Last Scanned on 2024-11-18
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 MoreOther packages similar to @react-native-picker/picker
react-native-web-picker
React Native for Web implementation of @react-native-picker/picker
react-native-modal-datetime-picker
A react-native datetime-picker for Android and iOS
react-native-date-picker
A datetime picker for React Native. In-modal or inlined. Supports Android and iOS.
react-native-document-picker
A react native interface to access documents from dropbox, google drive, iCloud...