TechnologiesSwiftUI

AutomaticNavigationSplitViewStyle struct

iOSmacOStvOSwatchOSvisionOSiOS 16.0+✓ renders

A navigation split style that resolves its appearance automatically

How it works

AutomaticNavigationSplitViewStyle is the default NavigationSplitViewStyle that SwiftUI applies to a NavigationSplitView when you don't request a specific one. Rather than fixing a layout, it lets the system choose how columns are presented and how they collapse or expand based on the platform, the size class, and the available space — showing side-by-side columns where there's room and falling back to a stacked, drill-in presentation where there isn't. Reach for it when you want a split-view interface that adapts to its environment automatically, deferring the column-visibility behavior to SwiftUI instead of pinning it down yourself.

  1. Get the automatic style for free on any NavigationSplitView

    Every NavigationSplitView already uses this style unless you override it, so the adaptive column behavior is the baseline. In the example, the NavigationSplitView with its sidebar List and detail closure receives AutomaticNavigationSplitViewStyle whether or not you mention it — it's what decides, at runtime, whether the Mailboxes sidebar and the detail Text sit beside each other or stack.

  2. Request it explicitly with .navigationSplitViewStyle(.automatic)

    Apply the style through the navigationSplitViewStyle(_:) modifier, passing the .automatic shorthand for AutomaticNavigationSplitViewStyle. In the example, .navigationSplitViewStyle(.automatic) is attached to the NavigationSplitView, documenting the intent to let SwiftUI manage the layout and making it easy to swap in .balanced or .prominentDetail later by changing this one call.

  3. Use .automatic as the NavigationSplitViewStyle conformance

    AutomaticNavigationSplitViewStyle conforms to the NavigationSplitViewStyle protocol, and the static .automatic member is the type-erased way to refer to it at a call site. Because the modifier takes any NavigationSplitViewStyle, .automatic slots in exactly where .balanced or .prominentDetail would, so the surrounding List and detail content stay unchanged when you experiment with styles.

  4. Let the style drive column visibility from the selection

    The automatic style coordinates how columns appear as the user navigates, which is why state flows cleanly between them. Here the @State selection bound through List(folders, id: \.self, selection: $selection) updates the detail Text(selection ?? "Select a folder"); on a compact width the automatic style collapses to a stack and a tap pushes the detail, while on a wide layout it reveals the detail column alongside the sidebar.

Try it — Change .navigationSplitViewStyle(.automatic) to .navigationSplitViewStyle(.prominentDetail) and compare how the detail Text claims space, to see what the automatic style was deciding on your behalf.

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.

AutomaticNavigationSplitViewStyle.swift
struct AutomaticNavigationSplitViewStyleDemo: View {
    @State private var selection: String? = "Inbox"
    let folders = ["Inbox", "Sent", "Drafts"]

    var body: some View {
        NavigationSplitView {
            List(folders, id: \.self, selection: $selection) { folder in
                Text(folder)
            }
            .navigationTitle("Mailboxes")
        } detail: {
            Text(selection ?? "Select a folder")
                .font(.title)
                .padding()
        }
        .navigationSplitViewStyle(.automatic)
    }
}
Live preview
fo… Inbox
fo… Inbox
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →