SweetUI

Search items

Jump to an item

recipe

sidebar

Sidebar: NavigationSplitView + selection-bound List (iPad).

sidebarnavigationsplit-viewipadguidance
sidebar, light

On iPad

The same installed source at a regular width. It adapts its layout without a separate design.

sidebar on iPad, light

Install

Usage

@State private var selection: String? = "activity"
@State private var tab = "activity"

NavigationSplitView {
    List(selection: $selection) {
        Label("Activity", systemImage: "bell").tag("activity")
        Label("Cards", systemImage: "creditcard").tag("cards")
    }
    .navigationTitle("Bank")
    .navigationSplitViewColumnWidth(min: 200, ideal: 240, max: 320)
} detail: {
    // A visually rich detail extends under the sidebar instead of stopping at its edge
    ActivityBanner()
        .backgroundExtensionEffect()
    if selection == "activity" { ActivityScreen() } else { CardsScreen() }
}
.registryItem("sidebar")

// The HIG's first choice on iPad: a tab bar people can switch to a sidebar
TabView(selection: $tab) {
    Tab("Activity", systemImage: "bell", value: "activity") { ActivityScreen() }
    Tab("Cards", systemImage: "creditcard", value: "cards") { CardsScreen() }
}
.tabViewStyle(.sidebarAdaptable)

Why native is enough

NavigationSplitView + selection-bound List: iPhone-stack, column-toggle; keyboard/pointer selection. MUST NOT rebuild via HStack. iPadOS drags divider (navigationSplitViewColumnWidth); iPhone ignores. TabView+.sidebarAdaptable first: tab-bar or sidebar, switches, adapts width (HIG pick). Else NavigationSplitView for sidebar-only. Rich detail extends beneath via backgroundExtensionEffect() (26.0), past edge (HIG: sidebar-over-content).

Accessibility contract

  • Sidebar rows: native cells, selection semantics.
  • Column toggle: system-provided, labeled.
  • Selection state: caller-owned via binding.
  • Tab/sidebar switch: system control, own label; tabs keep native semantics.
  • Background extension: mirrors pixels beneath sidebar; no accessibility element, hides nothing.

Details

Kindrecipe
Version0.3.1
PlatformsiOS 26.0+
Dependenciesnone
Sourcenone (native guidance)