Skills

Swiftui Navigation

Implement SwiftUI navigation patterns including NavigationStack, NavigationSplitView...

Install

npx skills add dpearson2699/swift-ios-skills --skill swiftui-navigation -g -a claude-code -y
Category
Documents
Updated
3mo ago
License
See repository
Context cost
Mediumabout 2,764 tokens
Runs scripts
No, instructions only

What it does

Implement SwiftUI navigation patterns including NavigationStack, NavigationSplitView, sheet presentation, tab-based navigation, and deep linking. Use when building push navigation, programmatic routing, multi-column layouts, modal sheets, tab bars, universal links, or custom URL scheme handling.

SwiftUI Navigation

Navigation patterns for SwiftUI apps targeting iOS 26+ with Swift 6.3. Covers push navigation, multi-column layouts, sheet presentation, tab architecture, and deep linking. Patterns are backward-compatible to iOS 17 unless noted.

Contents

NavigationStack (Push Navigation)

Use NavigationStack with a typed [Route] binding for programmatic push navigation. Define routes as a Hashable enum and map them with .navigationDestination(for:); this keeps the path compile-time checked. Use NavigationPath only when one stack must hold heterogeneous route value types.

enum Route: Hashable {
    case item(id: Item.ID)
}

struct ContentView: View {
    @State private var path: [Route] = []
    let items: [Item]

    var body: some View {
        NavigationStack(path: $path) {
            List(items) { item in
                NavigationLink(value: Route.item(id: item.id)) {
                    ItemRow(item: item)
                }
            }
            .navigationDestination(for: Route.self) { route in
                switch route {
                case .item(let id):
                    DetailView(itemID: id)
                }
            }
            .navigationTitle("Items")
        }
    }
}

Programmatic navigation:

path.append(.item(id: item.id))  // Push
path.removeLast()                // Pop one
path = []                        // Pop to root
Read the whole SKILL.md on GitHub

More in Documents