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.
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
NavigationSplitViewwith its sidebarListanddetailclosure receivesAutomaticNavigationSplitViewStylewhether or not you mention it — it's what decides, at runtime, whether theMailboxessidebar and the detailTextsit beside each other or stack.Request it explicitly with .navigationSplitViewStyle(.automatic)
Apply the style through the
navigationSplitViewStyle(_:)modifier, passing the.automaticshorthand forAutomaticNavigationSplitViewStyle. In the example,.navigationSplitViewStyle(.automatic)is attached to theNavigationSplitView, documenting the intent to let SwiftUI manage the layout and making it easy to swap in.balancedor.prominentDetaillater by changing this one call.Use .automatic as the NavigationSplitViewStyle conformance
AutomaticNavigationSplitViewStyle conforms to the NavigationSplitViewStyle protocol, and the static
.automaticmember is the type-erased way to refer to it at a call site. Because the modifier takes any NavigationSplitViewStyle,.automaticslots in exactly where.balancedor.prominentDetailwould, so the surroundingListanddetailcontent stay unchanged when you experiment with styles.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
@Stateselectionbound throughList(folders, id: \.self, selection: $selection)updates thedetailText(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.
.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.
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)
}
}