TechnologiesSwiftUI

DefaultTabViewStyle struct

iOSmacOStvOSwatchOSvisionOSiOS 14.0+✓ renders

The default tab view style.

How it works

DefaultTabViewStyle is the TabViewStyle that SwiftUI applies to a TabView when you don't request a specific style of your own. It resolves to whatever presentation is idiomatic for the current platform and context — a tab bar on iOS, a top tab strip on watchOS, a sidebar or tab bar on iPadOS — so a TabView looks native everywhere without you hardcoding an appearance. Reach for it when you want the system's standard behavior, or when you need to explicitly fall back to that behavior after another style was set higher in the view hierarchy.

  1. Build the container with TabView

    DefaultTabViewStyle styles a TabView, so the symbol only comes into play once you have a tab container. Here TabView wraps two pages, the Text("Home") and Text("Settings") screens, each of which becomes one selectable tab.

  2. Identify each tab with tabItem

    The default style draws one entry per child that carries a .tabItem modifier, using the Label inside it for the tab's title and glyph. The example supplies a Label("Home", systemImage: "house") and a Label("Settings", systemImage: "gear"), which the default presentation renders as the standard tab-bar items.

  3. Select the style with tabViewStyle(.automatic)

    You apply a TabViewStyle through the .tabViewStyle(_:) modifier. Passing .automatic — the shorthand that resolves to DefaultTabViewStyle — tells SwiftUI to use the platform's standard tab presentation. Because .automatic is also what an unstyled TabView already uses, naming it here makes the intent explicit and overrides any non-default style inherited from an ancestor view.

  4. Let the style adapt to the platform

    DefaultTabViewStyle carries no configuration of its own; its whole job is to pick the right look for where the view runs. The same .tabViewStyle(.automatic) call yields a bottom tab bar on iPhone and the system-appropriate layout elsewhere, with surrounding modifiers like .padding() left to handle spacing rather than appearance.

Try it — Change .tabViewStyle(.automatic) to .tabViewStyle(.page) to see the tabs become a swipeable paged carousel, then switch it back to confirm DefaultTabViewStyle restores the standard tab-bar presentation.

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.

DefaultTabViewStyle.swift
struct DefaultTabViewStyleDemo: View {
    var body: some View {
        TabView {
            Text("Home")
                .tabItem {
                    Label("Home", systemImage: "house")
                }
            Text("Settings")
                .tabItem {
                    Label("Settings", systemImage: "gear")
                }
        }
        .tabViewStyle(.automatic)
        .padding()
    }
}
Live preview
Home Home Home Settings
Home Home Home Settings
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →