How it works
AutomaticNavigationTransition is the default transition that SwiftUI applies when a destination is pushed onto or popped from a navigation stack. Rather than committing you to a specific animation, it lets the system choose the most appropriate effect for the current platform, presentation style, and context — including the zoom transition that pairs a tapped source view with its destination when one is available. Reach for it when you want navigation animations that stay consistent with system conventions, or when you want to restore the default behavior after applying a more specific transition elsewhere.
Apply the transition with navigationTransition(_:)
You don't construct
AutomaticNavigationTransitiondirectly; you select it through thenavigationTransition(_:)view modifier attached to a navigation destination. In the example,.navigationTransition(.automatic)is placed on theText("Detail Screen")destination so the push and pop are animated by the system's chosen transition.Reference it through the .automatic shorthand
AutomaticNavigationTransitionconforms toNavigationTransition, and that protocol exposes a staticautomaticmember so you can write the dotted form.automaticinstead of naming the type. This is the value you pass tonavigationTransition(_:), as shown by.navigationTransition(.automatic).Host the destination in a NavigationStack
A navigation transition only has meaning where SwiftUI drives navigation, so the modifier takes effect on a destination presented inside a stack. Here the
NavigationLink("Show Detail")lives in aNavigationStack, andAutomaticNavigationTransitiongoverns how that detail is brought on screen when the link is activated.Let the system resolve the concrete effect
Because the transition is automatic, SwiftUI decides at runtime whether to use a standard slide, a zoom, or another platform-appropriate effect — you express intent, not a fixed animation. Applying
.automaticto theText("Detail Screen")view opts that destination into whatever the system considers correct rather than overriding it.
.navigationTransition(.automatic) with .navigationTransition(.zoom(sourceID: "detail", in: namespace)) (adding a matching .matchedTransitionSource(id:in:) on the link) to see how a specific transition diverges from the system-chosen one.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct AutomaticNavigationTransitionDemo: View {
var body: some View {
NavigationStack {
NavigationLink("Show Detail") {
Text("Detail Screen")
.font(.title)
.navigationTransition(.automatic)
}
.padding()
.navigationTitle("Home")
}
}
}