View Transitions API

On this page 7

The View Transitions API is a browser interface that creates animated transitions between two visual states of a page, or between two pages of the same site, by capturing snapshots of the old and new states and animating between them with CSS. Among Web APIs, it fills a gap that previously required heavy JavaScript animation libraries or complex manual coordination of the DOM.

The API covers two scenarios. Same-document transitions animate DOM updates inside a single page, typical for single-page applications, while cross-document transitions animate ordinary navigations between same-origin pages of a multi-page Web site. In both cases the browser does the heavy lifting of capturing and compositing, and developers control the motion with standard CSS animations.

How the View Transitions API captures and animates states

A same-document transition starts with a call to document.startViewTransition(), which receives a callback that updates the DOM. The browser then follows a fixed sequence: it captures the current state, pauses rendering, runs the update, captures the new state and animates between the two snapshots.

  1. The browser takes a snapshot of the old state, including every element that carries a view-transition-name.
  2. Rendering is briefly frozen while the update callback changes the DOM, so users never see an intermediate state.
  3. The browser captures the new state as live representations of the updated elements.
  4. It builds a pseudo-element tree on top of the page and runs CSS animations, by default a crossfade.
  5. When the animations finish, the overlay is removed and the real updated page becomes visible and interactive.

The overlay is described by a tree of pseudo-elements, and each one can be targeted with CSS. Understanding this tree is the key to customizing the animation without any JavaScript animation code.

Pseudo-elementWhat it representsTypical customization
::view-transitionRoot overlay above the pageRarely styled directly
::view-transition-group(name)Container that morphs size and positionDuration and easing of movement
::view-transition-image-pair(name)Holder for old and new imagesIsolation and blending
::view-transition-old(name)Static snapshot of the old stateFade-out or slide-out keyframes
::view-transition-new(name)Live view of the new stateFade-in or slide-in keyframes
Pseudo-elements created during a view transition

Shared element transitions with view-transition-name

The CSS property view-transition-name marks an element as a separately animated participant. When an element in the old state and an element in the new state share the same name, the browser treats them as one object and morphs its position and size between the two layouts, which produces the familiar effect of a thumbnail expanding into a hero image.

Each name must be unique on the page at capture time; if two visible elements carry the same name, the transition is skipped. For lists with many items, developers assign names dynamically, use the match-element value in supporting browsers, or group styling with view-transition-class, so that dozens of items can share one animation rule.

Same-document and cross-document transitions compared

The two variants share the same pseudo-element model but differ in how a transition is triggered and which architecture they serve. The following table summarizes the practical differences.

AspectSame-documentCross-document
Triggerdocument.startViewTransition() in scriptNormal navigation between pages
Opt-inCalling the methodCSS rule @view-transition { navigation: auto; } on both pages
Typical architectureSingle-page applicationMulti-page site or server-rendered pages
Origin requirementNot applicableBoth pages must be same-origin
Script hooksPromises on the ViewTransition objectpageswap and pagereveal events
JavaScript requiredYesNo, CSS alone is sufficient
Two kinds of view transitions

Cross-document transitions are significant because they give multi-page architectures the smooth feel that was once a main argument for single-page applications, without client-side routing or hydration.

Controlling transitions from JavaScript

The startViewTransition() method returns a ViewTransition object that exposes the lifecycle of the transition. Its promises let code wait for specific moments, and its methods allow a transition to be skipped or classified.

MemberResolves or acts whenCommon use
updateCallbackDoneThe DOM update callback has finishedContinue logic that depends on new DOM
readyThe pseudo-element tree existsStart custom Web Animations API effects
finishedThe animation has endedClean up names or restore focus
skipTransition()Called by scriptApply the update without animation
typesSet at start or during navigationChoose different animations by direction
Members of the ViewTransition object

Transition types allow one stylesheet to define several animations, for example a slide to the left for forward navigation and a slide to the right for back navigation, selected with the :active-view-transition-type() pseudo-class.

Browser support, accessibility and common pitfalls

Support arrived in stages: Chromium-based browsers shipped same-document transitions first and later cross-document transitions, Safari followed with both variants in version 18 releases, and Firefox added same-document support in 2025. Because the API is a progressive enhancement, the standard pattern checks for document.startViewTransition and simply applies the update directly when it is missing.

Motion can cause discomfort for some users, so transitions should respect the prefers-reduced-motion media query, either by removing animations or by shortening them to a gentle fade. The table below lists frequent problems and their fixes.

SymptomLikely causeFix
Transition skipped entirelyDuplicate view-transition-name valuesMake names unique per capture
Page feels unresponsiveSlow update callback freezes renderingFetch data before starting the transition
Distorted text during morphAspect ratio change between snapshotsAdjust object-fit on old and new images
Clicks ignored mid-animationOverlay snapshots are not interactiveKeep durations short, around 200-400 ms
Cross-page animation missingOpt-in rule present on only one pageAdd @view-transition to both documents
Typical problems with view transitions

A further subtlety is that the old state is a flat image, so content inside it, such as a playing video, freezes during the animation. Elements with view-transition-name also form their own stacking context, which can change how they overlap other content.

Stripped to the essentials

When a page changes, the browser normally swaps the old content for the new content in an instant. The View Transitions API lets the browser take a picture of the page before the change, make the change, and then smoothly blend or slide from the picture to the new view.

Think of a photo album where one picture gently grows into a full-page print instead of the page simply flipping. The developer only describes the motion in CSS, and the browser handles the hard parts. If an older browser does not understand the feature, the page still changes as usual, just without the animation.

Where it is applied

A regional news publisher runs a server-rendered multi-page site with article lists and article pages. To make browsing feel smoother on phones, the frontend team adds the @view-transition rule to every template and assigns view-transition-name to each teaser image and to the matching hero image on the article page, using the article identifier in the name to keep every name unique.

When a reader taps a teaser, the small image expands into the article header over about 300 ms while the rest of the page crossfades. A pagereveal handler sets a transition type when the reader returns with the back button, so the motion reverses direction. Users who enable reduced motion receive a simple 150 ms fade instead.

The change required no client-side router and no new JavaScript framework. Readers on browsers without support see ordinary page loads, so the team ships the feature as a pure enhancement and avoids rebuilding the site as a single-page application.