Stockio

View Transitions: Add Them Without Breaking Navigation

Add same-document View Transitions with safe fallbacks, unique snapshot names, reduced-motion handling, and navigation behavior that remains correct when animations fail.

By Aiko Tanaka

Motion Designer ·

On this page

The View Transitions API can animate between an old rendered state and a new one without requiring both live interfaces to remain mounted together. Its most important architectural rule is simple: the update must work without the animation. Navigation, focus, and data state remain application responsibilities.

Design two complete destination states

Before adding movement, make both screens visually complete. If a floating overlay belongs in the new state, use the glassmorphism generator to prototype its surface, then check legibility and rendering cost. Keep that surface static while testing the transition. The tool styles the destination; it does not implement the API or navigation.

A view transition captures visual states and animates a pseudo-element representation between them. That differs from leaving an old page interactive while a new one slides in. Treat the effect as a presentation layer, not as a replacement for ordinary document updates.

Start with same-document updates because they make ownership explicit. Cross-document transitions are a separate integration path with their own opt-in and navigation constraints. Do not assume a working client-side example automatically animates ordinary links between documents.

Wrap an existing update with a fallback

Keep the state update in a function that can run with or without API support. In this example, renderDestination represents an existing synchronous render operation that updates a region already managed by the application.

function showDestination(renderDestination) {
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!document.startViewTransition || reduce) {
  renderDestination();
  return;
}
const transition = document.startViewTransition(() => {
  renderDestination();
});
transition.finished.catch(() => {
  // Report diagnostics if needed; do not repeat the update here.
});
}

The fallback path performs the exact same update. It does not show a simplified page or wait for a timer. Avoid retrying the render when a transition promise rejects: an animation problem does not necessarily mean the underlying update failed.

Framework rendering may be asynchronous. Integrate through the framework's documented commit mechanisms rather than assuming a state setter has already changed the DOM when the callback returns. If the callback returns a promise, the API can wait for it, but that promise must represent the correct update boundary.

Read MDN's View Transition API overview for lifecycle details. Treat loading and rendering errors separately from transition readiness so an animation exception cannot swallow an actual navigation failure.

Name only the elements that need continuity

By default, the root snapshot can crossfade the page. A shared image or product card can receive its own transition name to establish a stronger visual connection. Names must be unique among participating rendered elements within each captured state.

.product-image { view-transition-name: selected-product; }
::view-transition-group(selected-product) {
animation-duration: 240ms;
}
@media (prefers-reduced-motion: reduce) {
::view-transition-group(*) {
  animation-duration: 0s;
}
}

Do not assign the same name to every card in a product grid. Apply it only to the selected item, and ensure the destination counterpart uses that name. Duplicate names can prevent the transition from becoming ready even when the DOM update itself succeeds.

Use stable visual correspondence rather than trying to animate everything. Naming a heading, image, sidebar, badge, and toolbar can create too many competing trajectories. A single recognizable image plus a quiet root transition is often easier to follow.

For name constraints and pseudo-element behavior, consult the MDN view-transition-name reference. Audit clipping, border radii, and image cropping at both ends because snapshot interpolation can expose differences that were invisible in static screenshots.

Keep navigation semantics outside the effect

A transition does not automatically update the URL, manage history, announce a destination, or put focus where it belongs. Use real links for navigation and preserve modifier-click behavior, opening in a new tab, and browser back and forward controls. The animation wrapper should not intercept every click indiscriminately.

After a client-side route change, apply the application's normal focus policy. Depending on the route, that might mean moving focus to the main heading after rendering or preserving focus during a local filter update. The right policy follows the task, not the duration of the snapshot animation.

Avoid waiting until finished to make essential controls available. Users may have motion disabled, skip the transition, or navigate again immediately. The application must already be in its new functional state while the visual presentation completes.

Use the accessibility guide for related focus and navigation considerations. Keep announcements sparse and meaningful; narrating every visual movement adds noise without explaining the destination.

For cross-document transitions, review the Chrome documentation and verify current browser support. Treat that as a separate progressive enhancement project rather than expanding this same-document helper until it manages every navigation type.

Test rapid navigation and expensive snapshots

Test three quick route selections, back navigation during an effect, and a route whose images arrive late. The desired result is always the most recent valid destination, not the completion of every animation request. Choose a policy for skipping or superseding an active effect rather than building an unbounded visual queue.

Watch memory and rendering cost on large pages. Snapshots and large composited surfaces are not free. A translucent full-screen overlay can also make intermediate frames look unexpectedly muddy. The glass surface performance guide provides useful context for keeping those visual layers restrained.

Inspect screenshots at the beginning, midpoint, and end. A shared image with different aspect ratios can appear to stretch or jump even when the transition technically succeeds. Align cropping behavior and choose whether the shared snapshot or a simple crossfade communicates the change better.

Document the failure contract: if capture, readiness, or animation fails, the destination still renders once, history stays correct, and focus remains usable. Include reduced motion, unsupported browsers, duplicate-name mistakes, and removed nodes in that review. These cases distinguish a reliable navigation enhancement from a polished but brittle demo.

Test interruption rather than only completion

Navigate twice quickly while the first transition is still running. The final URL, selected navigation item, page heading, and visible content must all describe the latest destination. Do not disable ordinary navigation solely to protect an animation. Use the application's existing cancellation or stale-result handling so a slower earlier request cannot overwrite the newest screen.

Repeat with a failed destination request and with browser back navigation. Decide which complete state appears on failure before adding animation: an error destination, the previous screen, or an inline recovery state. A rejected transition promise is not itself evidence that navigation failed, so keep animation diagnostics separate from routing and data errors.

Finally, test keyboard focus after interruption. The snapshot is not a second interactive page, and focus should follow the committed application state rather than whichever visual image is currently fading. Check the result with reduced motion enabled too; removing the animation should not remove the same focus and history behavior.

Key takeaways

  • Build functional updates first, then add the snapshot animation.
  • Give shared elements unique, intentional transition names.
  • Keep URL, history, focus, and errors outside animation completion.
  • Test rapid navigation and preserve the same destination in every fallback.
Featured sponsor

Reach designers & developers at work

Put your product next to the tools people use every day. One sponsor per placement, no tracking pixels.

Become a sponsor

Keep reading

Related articles

More in Motion & Animation
UI Design

12 Best UI Design Inspiration Websites

Find twelve reliable places to study interface design, from curated galleries to real products, plus simple ways to turn visual references into useful ideas for your next screen.

Includes: GlassmorphismTheo OkaforTheo Okafor
UI Design

Glassmorphism CSS: Build UI Cards Without Hurting Speed

Build readable glassmorphism cards with practical blur limits, accessible fallbacks, and a repeatable profiling workflow for smoother production interfaces.

Includes: GlassmorphismMaya LindqvistMaya Lindqvist
Motion & Animation

10 Best Motion Design Tools for Beginners

Compare ten approachable motion design tools for simple titles, interface animations, and short videos. Find an entry point that matches your budget, device, and creative goals.

Includes: GradientsAiko TanakaAiko Tanaka
Motion & Animation

12 Best CSS Animation Generators and Resources

Compare twelve CSS animation references, visual generators and libraries, from easing curve playgrounds to ready-made effects, and find a sensible fit for your web project.

Includes: Box shadowsAiko TanakaAiko Tanaka
Motion & Animation

8 Best Prototyping Tools for Interactive Designs

Compare eight interactive prototyping tools for interface flows, animated websites and detailed device behaviour, with practical strengths and limitations to guide your choice.

Includes: Aspect ratioAiko TanakaAiko Tanaka
Motion & Animation

10 Best JavaScript and CSS Animation Libraries

Compare ten web animation libraries for interface feedback, scrolling effects, and expressive motion. Find a practical match for your coding comfort, project size, and performance needs.

Includes: Flexbox playgroundAiko TanakaAiko Tanaka