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.
A picker component that allows users to select from a list of options with different display styles.
Installation
- 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
import { Host, Picker } from '@expo/ui/swift-ui'; <Host matchContents> <Picker options={['$', '$$', '$$$', '$$$$']} selectedIndex={selectedIndex} onOptionSelected={({ nativeEvent: { index } }) => { setSelectedIndex(index); }} variant="segmented" /> </Host>
See official SwiftUI documentation for more information.
Wheel picker
The wheel variant is not available on Apple TV.
import { Host, Picker } from '@expo/ui/swift-ui'; <Host style={{ height: 100 }}> <Picker options={['$', '$$', '$$$', '$$$$']} selectedIndex={selectedIndex} onOptionSelected={({ nativeEvent: { index } }) => { setSelectedIndex(index); }} variant="wheel" /> </Host>
See official SwiftUI documentation for more information.
API
Component
Type: React.Element<PickerProps>
Displays a native picker component
Example
<Picker modifiers={[pickerStyle('segmented')]}> <Text modifiers={[tag('option1')]}>Option 1</Text> <Text modifiers={[tag(0)]}>Option 3</Text> </Picker>
React.ReactNodeThe content of the picker. You can use Text components with tag modifiers to display the options.
unionA label displayed on the picker.
Acceptable values are: string | React.ReactNode
(event: {
nativeEvent: {
selection: string | number
}
}) => voidCallback function that is called when an option is selected.
Gets called with the selected tag value.
unionThe selected option's tag modifier value.
Acceptable values are: string | number | null
SFSymbolThe name of the system image (SF Symbol). For example: 'photo', 'heart.fill', 'star.circle'