Value Tab View
Creates a tab view that uses a builder to create and specify selection values for its tabs.
Platform Compatibility
Tags
SwiftUI Code
@State var selection = "1"
var body: some View {
let displayedSelection = Text("Selected: \(selection)")
TabView(selection: $selection) {
Tab(value: "0") {
displayedSelection
}
Tab("1", systemImage: "1.circle", value: "1") {
displayedSelection
}
Tab("2", image: "cats24x24", value: "2") {
displayedSelection
}
Tab(value: "3") {
displayedSelection
} label: {
Label("3", systemImage: "3.circle")
}
}
}Found an issue or have a suggestion?
More TabView Components
View allDefault Tab Bar Placement
Specifies the preferred placement for the tabs of a TabView in the sidebarAdaptable style on platforms where the tab bar cannot adapt between different representations, and only one representation can be shown. For example, on iOS, it can enforce the sidebar on large-screen devices like the Pro Max, and iPhone Duo. This modifier has no effect on iPadOS.
Default Collapsed Tab Section
Sets the default expansion state for the section containing this tab to collapsed when displayed in the sidebar.
Tab View Customization Behavior
Configures the customization behavior of customizable tab view content.
Tab View Customization
Specifies the customizations to apply to the sidebar representation of the tab view.
Explore Other Components
Browse allAccessoryCircularCapacityGaugeStyle
A gauge style that displays a closed ring that’s partially filled in to indicate the gauge’s current value
Custom Slider Ticks
Creates a slider to select a value from a given range, subject to a step increment, which displays the provided labels and customizable ticks.
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.
Pinned Toolbar Item Placement
A placement that pins the item to the trailing edge of the toolbar.
Custom Placeholder Async URL Image
Loads and displays a modifiable image from the specified URL load request using a custom placeholder until the image loads.