Get a comprehensive overview of the Navigator
API and its components.
Central class for managing navigation paths and modals.
path: NavigationPath
- Represents the current navigation stack.alert: NavigatorAlert?
- The currently presented alert.sheet: NavigatorSheet?
- The currently presented sheet.confirmDialog: NavigatorConfirmDialog?
- The currently presented confirmation dialog.
-
append(_ value: Hashable) - Navigate to a new view.
navigator.append( YourDestination() )
-
removeLast(_ count: Int = 1) - Navigate back by removing views from the stack.
navigator.removeLast( count: 2 )
-
popToRoot() - Reset navigation to the root view.
navigator.popToRoot()
-
alert(title:message:actions:) - Present an alert.
navigator.alert( title: "Alert Title", message: { Text("Alert Message") }, actions: { NavigatorButton("OK") { $0.dismiss() } } )
-
sheet(content:onDismiss:) - Present a sheet.
navigator.sheet( content: { SheetView() }, onDismiss: { // Optional dismissal action } )
-
confirmDialog(title:message:actions:) - Present a confirmation dialog.
navigator.confirmDialog( title: "Confirm Action", message: { Text("Are you sure?") }, actions: { NavigatorButton("Yes") { $0.dismiss() } NavigatorButton("No") { $0.dismiss() } } )
-
dismiss() - Dismiss the current modal or navigate back.
navigator.dismiss()
Discover patterns and best practices to design scalable and maintainable navigation flows.