NavigationStack
NavigationStack is a container that manages a stack of views for navigation. NavigationStack provides navigation functionality similar to iOS navigation controllers, allowing users to navigate forward and backward through a hierarchy of views.
NavigationStack is a container that manages a stack of views for navigation. NavigationStack provides navigation functionality similar to iOS navigation controllers, allowing users to navigate forward and backward through a hierarchy of views.
Examples
Basic Usage
Preview unavailable for this example in the static docs build.
Show code
<NavigationStack>
<VStack spacing={20}>
<NavigationLink destination={Messages}>Message</NavigationLink>
<NavigationLink destination={About}>About</NavigationLink>
<NavigationLink destination={ZStackView}>ZStack</NavigationLink>
</VStack>
</NavigationStack>Preloaded Path
Preview unavailable for this example in the static docs build.
Show code
<NavigationStack {...args}>
<VStack spacing={20}>
<NavigationLink destination={Messages}>Message</NavigationLink>
<NavigationLink destination={About}>About</NavigationLink>
<NavigationLink destination={ZStackView}>ZStack</NavigationLink>
</VStack>
</NavigationStack>API
This component currently relies on inherited element props.
Overview
NavigationStack is a container that manages a stack of views for navigation. NavigationStack provides navigation functionality similar to iOS navigation controllers, allowing users to navigate forward and backward through a hierarchy of views.
SwiftUI Correspondence: Similar to SwiftUI's NavigationStack.
Notes
- NavigationStack manages the navigation hierarchy
- Use NavigationLink to navigate between views
- NavigationStack automatically handles back navigation
- Pages can be StandardPage or custom components
- NavigationStack supports different page types (page, actionsheet)
- Use
defaultPathto render an already-pushed destination on first load - Use
onPathChangeto observe the public stack shape without reading internal_idvalues
Best Practices
- Page structure: Use StandardPage for consistent page layouts
- Navigation flow: Design clear navigation flows that users can understand
- Back navigation: Back navigation is handled automatically
- Deep linking: Consider deep linking support for important views
- State management: Manage navigation state appropriately for your app