React Native Picker for iOS, Android, macOS, and Windows
npx @tessl/cli install tessl/npm-react-native-picker--picker@2.11.0React Native Picker is a cross-platform picker component for React Native applications that provides dropdown/select interfaces on iOS, Android, macOS, and Windows platforms. It offers extensive customization options including item colors, fonts, selection colors, and platform-specific features like dialog/dropdown modes on Android and programmatic open/close functionality. The library maintains native performance through platform-specific implementations while providing a unified JavaScript interface.
npm install @react-native-picker/pickerimport { Picker, PickerIOS, PickerProps, PickerItemProps } from "@react-native-picker/picker";For CommonJS:
const { Picker, PickerIOS, PickerProps, PickerItemProps } = require("@react-native-picker/picker");import React, { useState } from "react";
import { Picker } from "@react-native-picker/picker";
function App() {
const [selectedLanguage, setSelectedLanguage] = useState("js");
return (
<Picker
selectedValue={selectedLanguage}
onValueChange={(itemValue, itemIndex) =>
setSelectedLanguage(itemValue)
}>
<Picker.Item label="Java" value="java" />
<Picker.Item label="JavaScript" value="js" />
<Picker.Item label="Python" value="python" />
</Picker>
);
}React Native Picker is built around several key components:
Picker component that renders platform-appropriate implementationsPicker.Item for defining selectable options with styling supportMain cross-platform picker component that automatically renders the appropriate platform-specific implementation. Supports controlled component pattern with extensive customization options.
interface PickerProps<T = ItemValue> extends ViewProps {
selectedValue?: T;
onValueChange?: (itemValue: T, itemIndex: number) => void;
style?: StyleProp<TextStyle>;
enabled?: boolean;
mode?: 'dialog' | 'dropdown';
itemStyle?: StyleProp<TextStyle>;
selectionColor?: ColorValue;
prompt?: string;
placeholder?: string;
testID?: string;
dropdownIconColor?: number | ColorValue;
dropdownIconRippleColor?: number | ColorValue;
numberOfLines?: number;
accessibilityLabel?: string;
onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
}
declare class Picker<T> extends React.Component<PickerProps<T>, {}> {
static readonly MODE_DIALOG: 'dialog';
static readonly MODE_DROPDOWN: 'dropdown';
static Item: React.ComponentType<PickerItemProps<T>>;
focus: () => void;
blur: () => void;
}Individual selectable items within a Picker component. Support styling, colors, fonts, and platform-specific features like disabled state.
interface PickerItemProps<T = ItemValue> {
label?: string;
value?: T;
color?: string;
fontFamily?: string;
testID?: string;
style?: StyleProp<TextStyle>;
enabled?: boolean;
}Enhanced picker component with iOS-specific features including theme variants, selection colors, and native iOS styling patterns.
interface PickerIOSProps extends ViewProps {
itemStyle?: StyleProp<TextStyle>;
style?: StyleProp<TextStyle>;
onChange?: React.SyntheticEvent<{itemValue: ItemValue, itemIndex: number}>;
onValueChange?: (itemValue: ItemValue, itemIndex: number) => void;
selectedValue?: ItemValue;
testID?: string;
numberOfLines?: number;
themeVariant?: string;
}
declare class PickerIOS extends React.Component<PickerIOSProps, {}> {
static Item: typeof PickerIOSItem;
}Platform-specific customization options and behaviors including Android dialog/dropdown modes, Windows placeholder support, and programmatic control methods.
// Android-specific props
interface AndroidPickerProps {
mode?: 'dialog' | 'dropdown';
enabled?: boolean;
prompt?: string;
dropdownIconColor?: ColorValue;
dropdownIconRippleColor?: ColorValue;
numberOfLines?: number;
onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
}
// Windows-specific props
interface WindowsPickerProps {
placeholder?: string;
}
// iOS-specific props
interface IOSPickerProps {
itemStyle?: StyleProp<TextStyle>;
selectionColor?: ColorValue;
themeVariant?: string;
}type ItemValue = number | string | object;
interface PickerIOSItemProps {
label?: string;
value?: number | string;
color?: string;
testID?: string;
}