This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
Picker
A SwiftUI Picker component for selecting options from a list.
iOS
tvOS
Expo UI Picker matches the official SwiftUI Picker API and supports all picker styles via the pickerStyle modifier.
Installation
Terminal
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
Segmented picker
SegmentedPickerExample.tsx
import { useState } from 'react'; import { Host, Picker, Text } from '@expo/ui/swift-ui'; import { pickerStyle, tag } from '@expo/ui/swift-ui/modifiers'; const options = ['Apple', 'Banana', 'Orange']; export default function SegmentedPickerExample() { const [selectedTag, setSelectedTag] = useState(options[0]); return ( <Host matchContents> <Picker modifiers={[pickerStyle('segmented')]} label="Select a fruit" selection={selectedTag} onSelectionChange={selection => { setSelectedTag(selection); }}> {options.map(option => ( <Text key={option} modifiers={[tag(option)]}> {option} </Text> ))} </Picker> </Host> ); }
Menu picker
MenuPickerExample.tsx
import { useState } from 'react'; import { Host, Picker, Text } from '@expo/ui/swift-ui'; import { pickerStyle, tag } from '@expo/ui/swift-ui/modifiers'; const options = ['Apple', 'Banana', 'Orange']; export default function MenuPickerExample() { const [selectedTag, setSelectedTag] = useState(options[0]); return ( <Host matchContents> <Picker modifiers={[pickerStyle('menu')]} label="Select a fruit" selection={selectedTag} onSelectionChange={selection => { setSelectedTag(selection); }}> {options.map(option => ( <Text key={option} modifiers={[tag(option)]}> {option} </Text> ))} </Picker> </Host> ); }
Wheel picker
The wheel variant is not available on Apple TV.
WheelPickerExample.tsx
import { useState } from 'react'; import { Host, Picker, Text } from '@expo/ui/swift-ui'; import { pickerStyle, tag } from '@expo/ui/swift-ui/modifiers'; const options = ['Apple', 'Banana', 'Orange']; export default function WheelPickerExample() { const [selectedTag, setSelectedTag] = useState(options[0]); return ( <Host matchContents> <Picker modifiers={[pickerStyle('wheel')]} label="Select a fruit" selection={selectedTag} onSelectionChange={selection => { setSelectedTag(selection); }}> {options.map(option => ( <Text key={option} modifiers={[tag(option)]}> {option} </Text> ))} </Picker> </Host> ); }
API
import { Picker } from '@expo/ui/swift-ui';
No API data file found, sorry!