This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
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. Depending on the variant it can be a segmented button, an inline picker, a list of choices or a radio button.
stringA label displayed on the picker when in 'menu' variant inside a form section on iOS.
(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
string • Default: 'segmented'The variant of the picker, which determines its appearance and behavior.
The 'inline' variant can only be used inside sections or lists. The 'palette' variant displays differently inside menus.
Note: The
wheelvariant is not available on tvOS.
Acceptable values are: 'wheel' | 'segmented' | 'menu' | 'inline' | 'palette'