This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
Picker
A Jetpack Compose Picker component for selecting options from a list.
Expo UI Picker matches the official Jetpack Compose Segmented Button and Radio Button APIs and supports segmented and radio picker variants.
Installation
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Segmented picker
Use the variant="segmented" prop to display a segmented button group.
import { useState } from 'react'; import { Host, Picker } from '@expo/ui/jetpack-compose'; export default function SegmentedPickerExample() { const [selectedIndex, setSelectedIndex] = useState(0); return ( <Host matchContents> <Picker options={['$', '$$', '$$$', '$$$$']} selectedIndex={selectedIndex} onOptionSelected={({ nativeEvent: { index } }) => { setSelectedIndex(index); }} variant="segmented" /> </Host> ); }
Radio picker
Use the variant="radio" prop to display a list of radio buttons.
import { useState } from 'react'; import { Host, Picker } from '@expo/ui/jetpack-compose'; export default function RadioPickerExample() { const [selectedIndex, setSelectedIndex] = useState(0); return ( <Host matchContents> <Picker options={['Small', 'Medium', 'Large']} selectedIndex={selectedIndex} onOptionSelected={({ nativeEvent: { index } }) => { setSelectedIndex(index); }} variant="radio" /> </Host> ); }
Picker with custom color
Use the color prop to customize the picker's accent color.
import { useState } from 'react'; import { Host, Picker } from '@expo/ui/jetpack-compose'; export default function CustomColorPickerExample() { const [selectedIndex, setSelectedIndex] = useState(0); return ( <Host matchContents> <Picker options={['Option A', 'Option B', 'Option C']} selectedIndex={selectedIndex} onOptionSelected={({ nativeEvent: { index } }) => { setSelectedIndex(index); }} variant="segmented" color="#6200EE" /> </Host> ); }
API
import { Picker } from '@expo/ui/jetpack-compose';
Component
Type: React.Element<PickerProps>
Displays a native picker component. Depending on the variant it can be a segmented button, an inline picker, a list of choices or a radio button.
(event: {
nativeEvent: {
index: number,
label: string
}
}) => voidCallback function that is called when an option is selected.
unionThe index of the currently selected option.
Acceptable values are: number | null
Types
Colors for picker's core elements.
| Property | Type | Description |
|---|---|---|
| activeBorderColor(optional) | ColorValue | - |
| activeContainerColor(optional) | ColorValue | - |
| activeContentColor(optional) | ColorValue | - |
| disabledActiveBorderColor(optional) | ColorValue | - |
| disabledActiveContainerColor(optional) | ColorValue | - |
| disabledActiveContentColor(optional) | ColorValue | - |
| disabledInactiveBorderColor(optional) | ColorValue | - |
| disabledInactiveContainerColor(optional) | ColorValue | - |
| disabledInactiveContentColor(optional) | ColorValue | - |
| inactiveBorderColor(optional) | ColorValue | - |
| inactiveContainerColor(optional) | ColorValue | - |
| inactiveContentColor(optional) | ColorValue | - |