The problem
An iPad app used to have three or four layouts to worry about: full screen in two orientations, plus a couple of Split View widths. With resizable windows in iPadOS 26, a window can be any width from narrower than an iPhone to the full 13-inch display, and it can change while someone is using it. Layouts keyed to “is this an iPad” or to a few hard-coded widths break in the gaps. This article shows how to choose a navigation root that adapts by itself, when to trust size classes, and how to handle the rest with measured space.
Choose the root container by the shape of your content
The WWDC25 session Elevate the design of your iPad app frames the choice simply. A sidebar suits apps with a deep hierarchy, such as Mail or Music. A tab bar is a good default that can turn into a sidebar. In SwiftUI that becomes two options:
| Your content | Root | Minimum OS |
|---|---|---|
| A list of items that drill into detail (mail, notes, files, projects) | NavigationSplitView |
iOS 16 |
| A few distinct sections, each with its own navigation (Home, Library, Search) | TabView with .tabViewStyle(.sidebarAdaptable) |
iOS 18 |
| Both: sections, and inside one section a list-detail flow | TabView at the root, a NavigationStack inside each tab |
iOS 18 |
Don’t build your own sidebar out of an HStack and a List. The system containers handle collapsing, the sidebar toggle, keyboard focus, the menu bar’s View items and the scroll edge effect. Recreating all of that by hand is how iPad apps end up feeling like big phones.
NavigationSplitView: columns that collapse
NavigationSplitView (iOS 16) takes a sidebar, an optional content column and a detail. Majid Jabrayilov’s Mastering NavigationSplitView is still the clearest walkthrough. Each column’s root is wrapped in a navigation stack for you. Selection-bound lists drive the next column. navigationSplitViewColumnWidth(_:) and its min/ideal/max form set widths.
Two pieces of state make it behave on a resizable iPad:
columnVisibility, aNavigationSplitViewVisibility(iOS 16):.automatic,.all,.doubleColumnor.detailOnly. Natalia Panferova shows in Programmatically hide and show sidebar that.detailOnlyhides the sidebar in two columns and both leading columns in three. The system adds a sidebar toggle to the toolbar automatically.preferredCompactColumn, aNavigationSplitViewColumn(iOS 17): which column is on top when the split view collapses to one. Keith Harrison’s Compact Column Control explains why it matters. SwiftUI otherwise picks for you, usually the sidebar. The value has no visible effect while expanded and applies the next time the view collapses.
Collapse is no longer a phone-only case. Shrink an iPadOS 26 window far enough and your three-column layout becomes a stack. Bind both values:
import SwiftUI
struct Project: Identifiable, Hashable {
let id: UUID
var name: String
}
@Observable
final class ProjectStore {
var projects: [Project] = []
}
struct ProjectsRoot: View {
@Environment(ProjectStore.self) private var store
@State private var selection: Project.ID?
@State private var visibility: NavigationSplitViewVisibility = .automatic
@State private var compactColumn: NavigationSplitViewColumn = .sidebar
var body: some View {
NavigationSplitView(
columnVisibility: $visibility,
preferredCompactColumn: $compactColumn
) {
List(store.projects, selection: $selection) { project in
Label(project.name, systemImage: "folder")
}
.navigationTitle("Projects")
.navigationSplitViewColumnWidth(min: 240, ideal: 280, max: 360)
} detail: {
if let project = store.projects.first(where: { $0.id == selection }) {
ProjectDetail(project: project)
} else {
ContentUnavailableView("No project selected", systemImage: "folder")
}
}
.onChange(of: selection) { _, newValue in
compactColumn = newValue == nil ? .sidebar : .detail
}
}
}
struct ProjectDetail: View {
let project: Project
var body: some View {
Text(project.name)
.navigationTitle(project.name)
}
}
The onChange keeps the collapsed stack showing what the person was looking at. Choose a project in a wide window, narrow the window, and they stay on the project instead of being thrown back to the list. ContentUnavailableView is iOS 17, matching this article’s floor.
Session 208 also warns against column widths that cap how many columns fit. A sidebar with a large fixed width forces an early collapse. Give it a range and let the system resize it. UIKit split views on iPadOS 26 even let people drag the separators.
Sidebar-adaptable tabs (iOS 18)
Starting in iPadOS 18 the tab bar floats at the top of the screen, and with .sidebarAdaptable people can turn it into a sidebar and back. Apple’s Destination Video sample, written up in Enhancing your app’s content with tab navigation, shows the full set:
Tab(_:systemImage:value:content:)for each destination, with aHashableselection type.TabSectionto group secondary tabs under a header in the sidebar.Tab(value:role: .search)gets the standard title, symbol and a pinned trailing position.defaultVisibility(.hidden, for: .tabBar)keeps section tabs in the sidebar only.tabViewCustomization(_:)with aTabViewCustomizationin@AppStorage, andcustomizationID(_:)on each tab, lets people reorder and hide tabs.
In a compact width the same TabView becomes a bottom tab bar. Donny Wals ran into the catch in Using iOS 18’s new TabView with a sidebar. In compact width, every tab in every section went into the bottom bar, and the bar overflowed. His fix reads horizontalSizeClass and collapses each section to a single tab in compact width, reusing the same selection value so the selection survives the switch. Using size class here is correct, because the question is how a system container presents itself. defaultVisibility(.hidden, for: .tabBar) on the section is the other half of the fix.
import SwiftUI
enum AppTab: Hashable {
case today, library, search
case collection(String)
}
struct RootTabs: View {
@State private var selection: AppTab = .today
@AppStorage("tabCustomization") private var customization: TabViewCustomization
@Environment(\.horizontalSizeClass) private var sizeClass
private let collections = ["Travel", "Work", "Family"]
var body: some View {
TabView(selection: $selection) {
Tab("Today", systemImage: "sun.max", value: AppTab.today) {
NavigationStack { Text("Today").navigationTitle("Today") }
}
.customizationID("today")
Tab("Library", systemImage: "books.vertical", value: AppTab.library) {
NavigationStack { Text("Library").navigationTitle("Library") }
}
.customizationID("library")
if sizeClass == .regular {
TabSection("Collections") {
ForEach(collections, id: \.self) { name in
Tab(name, systemImage: "rectangle.stack", value: AppTab.collection(name)) {
NavigationStack { Text(name).navigationTitle(name) }
}
.customizationID("collection-\(name)")
}
}
.defaultVisibility(.hidden, for: .tabBar)
}
Tab(value: AppTab.search, role: .search) {
NavigationStack { Text("Search").navigationTitle("Search") }
}
}
.tabViewStyle(.sidebarAdaptable)
.tabViewCustomization($customization)
.onChange(of: sizeClass) { _, newValue in
if newValue == .compact, case .collection = selection {
selection = .library
}
}
}
}
If a collection is selected when the window goes compact, the onChange moves the selection to Library, where the collections also live as a list in the full app. Without it the TabView would point at a tab that no longer exists.
For deployment targets below iOS 18, keep the older TabView with .tabItem behind if #available(iOS 18, *) and accept a bottom tab bar on older iPads.
Combining tabs and a split view
Developers often try to put a NavigationSplitView inside a sidebar-adaptable tab. An Apple Developer Forums thread documents what happens. The window shows two sidebar buttons, the tab sidebar covers the split view’s sidebar, and the split view does not grow a third column when the tab bar becomes a sidebar. An Apple DTS engineer’s advice in that thread is to use one of the two as the top-level container, not both. I follow it. Inside a tab, use a NavigationStack, and put secondary detail in an inspector (inspector(isPresented:content:), iOS 17) instead of a second split view.
Sarah Reichelt notes in SwiftUI for Mac 2025 that .sidebarAdaptable only adapts to window size on iPad. On the Mac it stays a sidebar. If you ship the same code to both, check the Mac layout on its own.
Size class versus measured space
Fatbobman’s From Size Class to Available Space makes the case I follow here. horizontalSizeClass is a coarse signal of how system containers will behave. It is not a width. He wrote it after WWDC26 brought resizable windows to iPhone apps, both iPhone-only apps on iPad and iPhone Mirroring on the Mac, where a wide window can still report compact. His rules, which I recommend without reservation:
- Use size class for container semantics: tabs or sidebar, collapsed or expanded split view, sheet or popover.
- Use measured space for your own layout: grid columns, whether a form shows side by side, image sizes.
- Never use
UIDevice.current.userInterfaceIdiomorUIScreen.main.boundsfor layout.
SwiftUI has three good tools for rule two:
ViewThatFits(iOS 16) picks the first child that fits the proposed size. Ideal for “horizontal if it fits, vertical otherwise”.onGeometryChange(for:of:action:)(documented for iOS 16) reports a derived value from the view’s geometry. Return a small, coarseEquatablevalue, such as a column count, so it fires only when the layout should change.containerRelativeFrame(_:alignment:)(iOS 17) sizes a view as a fraction of its container, such as a card that is always one third of a scroll view’s width.
import SwiftUI
struct ProfileHeader: View {
let name: String
let bio: String
var body: some View {
ViewThatFits(in: .horizontal) {
HStack(alignment: .top, spacing: 20) {
avatar
details
}
VStack(alignment: .leading, spacing: 12) {
avatar
details
}
}
.padding()
}
private var avatar: some View {
Image(systemName: "person.crop.circle.fill")
.font(.system(size: 64))
.foregroundStyle(.secondary)
.accessibilityHidden(true)
}
private var details: some View {
VStack(alignment: .leading, spacing: 4) {
Text(name).font(.title2.bold())
Text(bio).font(.body).foregroundStyle(.secondary)
}
.frame(minWidth: 280, alignment: .leading)
}
}
The minWidth on details is what makes ViewThatFits choose. Without a minimum, the horizontal layout always “fits” by squeezing the text. This also handles Dynamic Type: at accessibility sizes the text needs more room and the header switches to vertical by itself.
Traps and edge cases
- Testing only full screen. The bugs hide in the middle widths, where a split view is about to collapse or a grid is about to drop a column. Drag the window slowly from your minimum to full width in both orientations.
- Selection lost on collapse. Without
preferredCompactColumn, a collapse can drop people back on the sidebar. Bind it. - Content scrolling under the sidebar. Apple’s tab navigation sample notes that horizontal
ScrollViewcontent scrolls under the sidebar with.sidebarAdaptableon iPadOS. Addclipped()or aclipShapeto the scroll view when that is not what you want. - Too many tabs. iPadOS collapses tabs that do not fit and makes the bar scroll. Keep top-level tabs few and put the rest in sections.
- Custom top bars and window controls. In a resizable window the window controls sit at the leading edge of the toolbar. System toolbars make room. Custom bars do not. See iPadOS 26 windowing for details.
- Per-window state. Each window has its own
@State. Keep the selection in the view hierarchy or@SceneStorage, not in a shared singleton, or two windows will fight over it.
Decision checklist
| Question | Answer | API |
|---|---|---|
| Deep list-to-detail content? | Split view | NavigationSplitView (iOS 16) |
| A few separate sections? | Adaptable tabs | TabView + .sidebarAdaptable (iOS 18) |
| What shows when collapsed? | Bind it | preferredCompactColumn (iOS 17) |
| Hide or show the sidebar from code? | Bind visibility | columnVisibility (iOS 16) |
| Compact tab bar overflowing? | Fewer tabs in compact | horizontalSizeClass, defaultVisibility(_:for:) |
| Side-by-side or stacked? | Let it measure | ViewThatFits (iOS 16) |
| Columns in a grid? | Derive from width | onGeometryChange(for:of:action:) |
| Secondary detail on the trailing side? | Inspector | inspector(isPresented:content:) (iOS 17) |
Resize the window down to your minimum, select something, resize back up, and check that the selection, scroll position and sidebar state all survived. If they did, the layout is adaptive. If they did not, the state is in the wrong place.
Sources and further reading
- Enhancing your app's content with tab navigation Apple Developer Documentation
- Elevate the design of your iPad app (WWDC25) Apple, WWDC25
- Mastering NavigationSplitView in SwiftUI Majid Jabrayilov, Swift with Majid
- SwiftUI SplitView Compact Column Control Keith Harrison, Use Your Loaf
- Programmatically hide and show sidebar in split view Natalia Panferova, Nil Coalescing
- Using iOS 18's new TabView with a sidebar Donny Wals
- From Size Class to Available Space: Is horizontalSizeClass Still Reliable? Fatbobman, Fatbobman's Blog
- iPadOS 18 TabView conflicts with NavigationSplitView Apple Developer Forums
- SwiftUI for Mac 2025 Sarah Reichelt, TrozWare