Picker
Creates a pickers with title, image, systemImage, and custom label.
Platform Compatibility
Tags
SwiftUI Code
@State var selection = "1"
let pickerOptions = ["1", "2", "3"]
var body: some View {
List {
Picker("Foo", selection: $selection) {
ForEach(pickerOptions, id: \.self) { option in
Text(option)
}
}
Picker("Bar", systemImage: "hand.tap", selection: $selection) {
ForEach(pickerOptions, id: \.self) { option in
Text(option)
}
}
Picker("Bar", image: .cats24X24, selection: $selection) {
ForEach(pickerOptions, id: \.self) { option in
Text(option)
}
}
Picker(selection: $selection) {
ForEach(pickerOptions, id: \.self) { option in
Text(option)
}
} label: {
Label("Foo", systemImage: "star")
Text("Bar")
}
}
}Found an issue or have a suggestion?
More Picker Components
View allTabsPickerStyle
A picker style that presents options as segmented tabs. On macOS, this style produces a segmented picker with a visual treatment that distinguishes tab navigation from value selection. On iOS, tvOS, and visionOS, the visual appearance matches that of the standard standard .segmented style. On all supported platforms, VoiceOver announces options as tabs.
Horizontal Radio Group Layout
Sets the style for radio group style pickers within this view to be horizontally positioned with the radio buttons inside the layout.
WheelPickerStyle
A picker style that presents the options in a scrollable wheel that shows the selected option and a few neighboring options.
SegmentedPickerStyle
A picker style that presents the options in a segmented control. Use this style when there are two to five options. Consider using menu when there are more than five options.
PalettePickerStyle
A picker style that presents the options as a row of compact elements. When used outside of menus, this style is rendered as a segmented picker. If that is the intended usage, consider segmented instead.
Explore Other Components
Browse allSwipe Action
Adds custom swipe actions to a row in a list or container, notifying you when the actions are revealed or dismissed.
Pinned Toolbar Item Placement
A placement that pins the item to the trailing edge of the toolbar.
StepperFieldDatePickerStyle
A system style that displays the components in an editable field, with adjoining stepper that can increment/decrement the selected component