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.
Build the container with TabView
DefaultTabViewStyle styles a
TabView, so the symbol only comes into play once you have a tab container. HereTabViewwraps two pages, theText("Home")andText("Settings")screens, each of which becomes one selectable tab.Identify each tab with tabItem
The default style draws one entry per child that carries a
.tabItemmodifier, using theLabelinside it for the tab's title and glyph. The example supplies aLabel("Home", systemImage: "house")and aLabel("Settings", systemImage: "gear"), which the default presentation renders as the standard tab-bar items.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.automaticis also what an unstyledTabViewalready uses, naming it here makes the intent explicit and overrides any non-default style inherited from an ancestor view.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.
.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.
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()
}
}