toolbarTitleAlignment

Sets the preferred alignment of the navigation bar's title.

Declaration

React
compose().toolbarTitleAlignment(
  alignment: SwiftUI.ToolbarTitleAlignment
)
Swift
nonisolated func toolbarTitleAlignment(
    _ alignment: ToolbarTitleAlignment
) -> some View

Parameters

Discussion

The navigation bar resolves the alignment of its title automatically based on context, and toolbar roles. Use this modifier to override that resolution.

NavigationStack {
    ContentView()
        .navigationTitle("Library")
        .toolbarTitleAlignment(.center)
}

See also

More in Navigation.