TechnologiesSwiftUI

TabPlacement struct

iOSmacOStvOSwatchOSvisionOSiOS 18.0+✓ renders

A place that a tab can appear.

How it works

TabPlacement describes where a tab is allowed to appear within an adaptable tab interface, letting you steer how individual tabs move between the bottom tab bar and the sidebar as a TabView reflows for different size classes and platforms. Each value expresses a placement policy for a single tab rather than for the container as a whole, so you can keep frequently used tabs always reachable while letting secondary ones fold into the sidebar. Reach for it when you adopt the sidebar-adaptable style and need finer control than the default behavior, pinning some tabs in place and tucking others away.

  1. Apply a placement with .tabPlacement(_:)

    TabPlacement values are attached to a Tab through the tabPlacement(_:) modifier, which records the policy on that tab so the surrounding TabView can honor it during layout. In the example each Tab carries its own call, such as the Home tab's .tabPlacement(.pinned), so placement is decided per tab instead of globally.

  2. Keep a tab visible with .pinned

    The pinned value asks the interface to keep a tab in the primary, always-visible position so it remains a one-tap target even as the layout adapts. Here .tabPlacement(.pinned) on the Home tab anchors it, signaling that it should not be collapsed into the sidebar.

  3. Tuck a tab away with .sidebarOnly

    The sidebarOnly value restricts a tab to the sidebar, removing it from the compact tab bar so it surfaces only when the sidebar is present. The Browse tab uses .tabPlacement(.sidebarOnly), marking it as secondary content that belongs in the expanded layout rather than the primary bar.

  4. Defer to the system with .automatic

    The automatic value hands the decision back to SwiftUI, which chooses a sensible placement based on the current style, platform, and available space. The Settings tab applies .tabPlacement(.automatic), opting into default behavior alongside its more opinionated siblings.

  5. Activate placement with .sidebarAdaptable

    TabPlacement only takes effect in a style that can present both a tab bar and a sidebar, since that is the layout these policies arbitrate. The example reaches that mode with .tabViewStyle(.sidebarAdaptable) on the TabView, which is what gives .pinned, .sidebarOnly, and .automatic something to act on.

Try it — Change the Browse tab's .tabPlacement(.sidebarOnly) to .tabPlacement(.pinned) and watch it move out of the sidebar into the always-visible tab bar.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

TabPlacement.swift
struct TabPlacementDemo: View {
    var body: some View {
        TabView {
            Tab("Home", systemImage: "house") {
                Text("Home")
                    .padding()
            }
            .tabPlacement(.pinned)

            Tab("Browse", systemImage: "square.grid.2x2") {
                Text("Browse")
                    .padding()
            }
            .tabPlacement(.sidebarOnly)

            Tab("Settings", systemImage: "gearshape") {
                Text("Settings")
                    .padding()
            }
            .tabPlacement(.automatic)
        }
        .tabViewStyle(.sidebarAdaptable)
        .padding()
    }
}
Live preview
Home Home Browse Settings
Home Home Browse Settings
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →