One Logo Pool Ball
SwiftUI · IOS API REFERENCE

TabViewCustomization

struct · iOS 18.0+ · SDK 27.1

struct TabViewCustomization

The customizations a person makes to an adaptable sidebar tab view. By default, if a person hasn't made customizations, tabs appear according to the default builder visibilities and sections appear in the order you declare in the tab view's tab builder. You can change the default visibility by using the ``TabContent/defaultVisibility(_:for:)`` with a ``AdaptableTabBarPlacement/sidebar`` placement. You can change the default section order by changing the order in the builder. If there's an existing persisted customization, reset the order by calling ``TabViewCustomization/SectionCustomization/resetTabOrder()`` when you change the order. All tabs and tab sections that support customization need to have a customization ID. You can mark a tab as being non-customizable by specifying a ``TabCustomizationBehavior/disabled`` behavior in all adaptable tab bar placements using ``TabContent/customizationBehavior(_:for:)-2u727``. On macOS, a default interaction is provided for reordering sections but not for controlling the visibility of individual tabs. A custom experience should be provided if desired by setting the visibility of the tab on the customization. The following code example uses `@AppStorage` to automatically persist any visibility or section order customizations a person makes. @AppStorage private var customization: TabViewCustomization TabView { Tab("Home", systemImage: "house") { MyHomeView() } .customizationID("com.myApp.home") Tab("Reports", systemImage: "chart.bar") { MyReportsView() } .customizationID("com.myApp.reports") TabSection("Categories") { Tab("Climate", systemImage: "fan") { ClimateView() } .customizationID("com.myApp.climate") Tab("Lights", systemImage: "lightbulb") { LightsView() } .customizationID("com.myApp.lights") } .customizationID("com.myApp.browse") } .tabViewStyle(.sidebarAdaptable) .tabViewCustomization($customization)

Members (8)

method · iOS 18.0+

resetVisibility

TypeScript
resetVisibility(): void
Swift declaration
mutating func resetVisibility()

Resets all tab sidebar visibilities back to the default, preserving the section customizations.

method · iOS 18.0+ · Deprecated in iOS 100000.0

resetSectionOrder

TypeScript
resetSectionOrderFor(sectionID: string): void
Swift declaration
mutating func resetSectionOrder(for sectionID: String)

Resets ordering back to the default for the section with `sectionID`, preserving any customized tab visibilities.

method · iOS 18.0+

resetSectionOrder

TypeScript
resetSectionOrder(): void
Swift declaration
mutating func resetSectionOrder()

Resets ordering back to the default for all sections, preserving the customized tab visibilities.

subscript · iOS 18.0+ · Deprecated in iOS 100000.0

subscript

TypeScript
subscriptSidebarVisibility(id: string): _SwiftUICore_Visibility
Swift declaration
subscript(sidebarVisibility id: String) -> Visibility { get set }

The visibility of the tab identified by its customization identifier. Visibility can be set imperatively by subscripting with the tab's id: customization[sidebarVisibility: "com.myApp.alerts"] = .hidden You can change the default visibility by using the ``TabContent/defaultVisibility(_:for:)`` with a ``AdaptableTabBarPlacement/sidebar`` placement. Tab("Alerts", systemImage: "bell", value: .alerts) { AlertsView() } .customizationID("com.myApp.alerts") .defaultVisibility(.hidden, for: .sidebar) If the ID isn't associated with a tab or the tab has not been customized, a default value of `.automatic` is returned.

subscript · iOS 18.4+

subscript

TypeScript
subscriptTab(id: string): TabViewCustomization_TabCustomization
Swift declaration
subscript(tab id: String) -> TabViewCustomization.TabCustomization { get set }

The customization of the tab, identified by its customization identifier. You can imperatively set properties by subscripting with the tab ID. The following example sets the tab's sidebar visibility: customization[tab: "com.myApp.alerts"].sidebarVisibility = .hidden

subscript · iOS 18.4+

subscript

TypeScript
subscriptSection(id: string): TabViewCustomization_SectionCustomization
Swift declaration
subscript(section id: String) -> TabViewCustomization.SectionCustomization { get set }

The customization of the section, identified by its customization identifier. Section tab order can be read by subscripting with the tab section's id: let order = customization[section: "com.myApp.categories"].tabOrder To reset the order of an individual section, use ``TabViewCustomization/SectionCustomization/resetTabOrder()``. To reset the order of all sections, use ``TabViewCustomization/resetSectionOrder()``.

subscript · iOS 18.0+ · Deprecated in iOS 100000.0

subscript

TypeScript
subscriptSectionID(id: string): (Array<string>) | null
Swift declaration
subscript(sectionID id: String) -> [String]? { get }

The customization for a section's children, identified by the section's customization identifier. Section order can be read by subscripting with the tab section's id: let order = customization[sectionID: "com.myApp.categories"] Identifiers can be associated with a `Tab` or `TabSection` using the `customizationID(_:)` modifier. TabSection("Categories") { Tab("Climate", systemImage: "fan") { ClimateView() } .customizationID("com.myApp.climate") Tab("Lights", systemImage: "lightbulb") { LightsView() } .customizationID("com.myApp.lights") } .customizationID("com.myApp.categories") If the ID isn't associated with a section or the section has not been customized, a default value of `nil` is returned.

init · iOS 18.0+

init

TypeScript
static init(): TabViewCustomization
Swift declaration
init()

Creates an empty tab sidebar customization. To set this customization on a tab view, use the ``View/tabViewCustomization(_:)`` modifier. With an empty customization, tabs will be visible according to the default builder visibilities, and sections will be ordered in the order declared in the tab view's tab builder. You can specify a default visibility for the tab in the tab bar and sidebar by attaching ``TabContent/defaultVisibility(_:for:)-17xo7`` to the tab. You can change the default section order by changing the order in the builder. If there's an existing persisted customization, reset the order by calling ``TabViewCustomization/SectionCustomization/resetTabOrder()`` when you change the order.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →