Contents

navigationViewStyle(_:)

Sets the style for navigation views within this view.

Declaration

nonisolated func navigationViewStyle<S>(_ style: S) -> some View where S : NavigationViewStyle

Discussion

Use this modifier to change the appearance and behavior of navigation views. For example, by default, navigation views appear with multiple columns in wider environments, like iPad in landscape orientation:

[Image]

You can apply the stack style to force single-column stack navigation in these environments:

NavigationView {
    List {
        NavigationLink("Purple", destination: ColorDetail(color: .purple))
        NavigationLink("Pink", destination: ColorDetail(color: .pink))
        NavigationLink("Orange", destination: ColorDetail(color: .orange))
    }
    .navigationTitle("Colors")

    Text("Select a Color") // A placeholder to show before selection.
}
.navigationViewStyle(.stack)

[Image]

See Also

Styling navigation views