Pages that morph

You will learn what the browser snapshots when you call startViewTransition, watch its pseudo-element tree in slow motion, test what your own browser supports, and take home transition timing you tuned yourself.

ArticleMotion
01

The cross-fade you get for free

The View Transitions API animates a DOM change in three steps. The browser takes a snapshot of the page before the change, lets you update the DOM, then animates from the old snapshot to the new view. Call document.startViewTransition(update) and you get a cross-fade with no other code. Give an element a view-transition-name and the browser also morphs it from its old position and size to its new one.

Start with the cross-fade. The box below switches between two states. With the switch off, the swap is instant. With it on, the same DOM change fades.

Swap the content Interactive
3 unread messages

Lunch on Friday? · Invoice ready · Build passed

Use startViewTransition
Press Swap content.

The readout lists the snapshots the browser took. With no names on the page there is only one, called root, and it covers the whole page. That is why everything cross-fades at once, even the parts that did not change. The measured time is usually a frame or two longer than the 250 ms default animation, because each snapshot waits for a rendering frame.

</> One call, with a fallback for older browsers.Show code
button.addEventListener('click', () => {
  if (!document.startViewTransition) return render(next);
  const t = document.startViewTransition(() => render(next));
  t.ready.catch(() => {}); // a skipped transition rejects here
});

One level deeper. The call always runs in the same order. The browser waits for the next frame and captures the old state as images. Then it pauses rendering and runs your callback, so a half-updated DOM is never painted. When the callback, or the promise it returns, settles, the browser captures the new state, builds a tree of pseudo-elements on top of the page and resolves transition.ready. The animations are ordinary CSS animations, and transition.finished resolves when they end. The browser animates pictures, not your elements, so the DOM change can be anything: display: none, a reordered list, a new route. You do not need the tricks from fading out of display: none. Keep the callback fast, though. Nothing repaints until it settles, and browsers give up on an update that takes too long.

02

Name it and it morphs

A name tells the browser that this thing in the old state is the same thing in the new state. Each named element gets its own pair of snapshots. Instead of fading where it stands, the pair travels from the old box to the new box while it cross-fades.

Open a card, then slow it down Interactive
Name the shared parts
Click a card. Press Escape or Back to return.

The speed slider adds no CSS. Once the transition is ready, it sets playbackRate on each animation the browser created, and it keeps doing so if you drag it mid-flight.

Set the speed to 0.10x and open a card. Three things show up that you would miss at full speed. The swatch grows smoothly, because its group animates width, height and transform. The title does not re-wrap or step through font sizes. It swells like a picture, because it is one. The other cards fade out as a single snapshot named vt-m-grid, and the card you clicked is missing from that image. A named child is lifted out of its parent's snapshot.

Now turn the names off and open a card again. You are back to one root snapshot, and the whole page cross-fades. Nothing travels.

In this demo the names exist only while a transition runs. The script puts them on the card before the call, moves them to the detail view inside the callback, and removes them when finished resolves. That keeps every name unique, which matters in section 4. The cards are buttons. Focus moves to Back when the detail opens and returns to the card when it closes.

</> Hand the name from the thumbnail to the detail image.Show code
function open(card) {
  const thumb = card.querySelector('.thumb');
  thumb.style.viewTransitionName = 'hero';
  const t = document.startViewTransition(() => {
    thumb.style.viewTransitionName = '';
    showDetail(card);
    detailImage.style.viewTransitionName = 'hero';
    detailClose.focus();
  });
  t.ready.catch(() => {});
  t.finished.then(() => { detailImage.style.viewTransitionName = ''; });
}
03

The tree the browser builds

While a transition runs, the browser draws a tree of pseudo-elements on top of the page. You cannot select them in the DOM. Their animations are real CSS animations, though, so document.getAnimations() can read them on every frame. The panel below does exactly that and prints what it finds.

Run a transition and read its tree Interactive
AB
Slow motion
Capture the root
Press Run and inspect. The tree appears while the transition runs, then freezes at its halfway frame.

The first run swaps A and B and brings in the New badge. Each name gets a group. Inside it is an image-pair, and inside that are the old and new images. The badge has only a new image, because it did not exist before, so it fades in. Run again and it has only old, so it fades out. Turn on Capture the root and a group(root) appears for the rest of the page.

Now read the durations. The page sets none, yet old and new report the same time as their group. The browser's default stylesheet makes them inherit the group's duration and delay, so timing the group times the whole branch. The animation names come from the browser engine and are not the same everywhere. The demo prints whatever your browser uses.

One level deeper. ::view-transition-old is a still image of the element as it was. ::view-transition-new is a live image of the element as it is now, so a video or spinner inside it keeps playing. Both behave like an img: they are sized to the group's width and keep their aspect ratio. That is why text scales during a morph instead of reflowing. While an element is captured, the browser does not paint the real element, only its images. The two images blend with plus-lighter, so a half-faded old image and a half-faded new image add up to a solid picture, with no see-through dip in the middle.

Every demo on this page sets view-transition-name: none on the html element while it runs, unless you ask for the root. Without a root snapshot, the browser does not capture the unnamed parts of the page at all. They stay painted live, and only the named parts animate.

</> Slow one transition to a tenth of its speed.Show code
const t = document.startViewTransition(update);
t.ready.then(() => {
  document.getAnimations()
    .filter(a => a.effect?.pseudoElement?.startsWith('::view-transition'))
    .forEach(a => { a.playbackRate = 0.1; });
});
04

One name, one element

Each view-transition-name must be unique among the rendered elements in each state. Elements with display: none do not count. Turn on the switch below to give tiles X and Y the same name, then run it. Tile Z keeps its own name, so you can see whether the rest of the transition survives.

Break it on purpose Interactive
XYZ
Same name on X and Y
Run it once with unique names, then turn on the switch.

Under the original rule, one duplicate name in either state skips the whole transition. transition.ready rejects with an InvalidStateError and nothing animates, not even Z. Your callback still runs, so the DOM still ends up in the right state. In 2026 the CSS Working Group agreed to soften the rule: only the duplicated name should stop animating, and the rest of the transition should still run. Browsers adopt changes like this at different times, so the readout reports which rule your browser follows today.

Either way, users see nothing wrong, and the only sign is in the console. Two habits prevent it. Attach a handler to ready on every transition. And build names from data you know is unique, such as a record id, or let the browser generate them.

</> Automatic unique names, styled as one class.Show code
.card {
  view-transition-name: match-element; /* unique per element */
  view-transition-class: card;
}

::view-transition-group(*.card) {
  animation-duration: 300ms;
}

match-element gives each element an automatic name tied to that element. view-transition-class lets one rule style all of those groups. Both arrived after the core API, so the next section checks them in your browser.

05

Between pages

The same machinery works across a full page load. Each page opts in with one at-rule. Elements with matching names on the old and new page then morph across the navigation. The transition only runs for same-origin navigations, and both pages must opt in.

</> Opt in to cross-document transitions.Show code
/* In the CSS of both pages (same origin) */
@view-transition {
  navigation: auto;
}

.product-photo {
  view-transition-name: product-photo;
}

Same-document transitions are Baseline. Chrome and Edge 111, Safari 18 and Firefox 144 support them. Cross-document transitions shipped in Chrome and Edge 126 and in Safari 18.2. At the time of writing, Firefox's support for them was still incomplete. Support for the newer features varies even more. So instead of a support table from memory, here is what your browser reports.

What this browser supports Interactive
  • Testing…
Running static checks…

The static checks use CSS.supports(). They also parse an @view-transition rule in a fresh stylesheet and look for the pageswap and pagereveal events. The live run goes further: it names the dot, starts a real transition and reports whether ready resolved. A rule that parses only proves the parser knows it. To be sure navigations animate, try two real pages.

One level deeper. A cross-document transition spans two documents, so it has a hook on each side. On the old page, pageswap fires before the last frame, and event.viewTransition is set if a transition will run. On the new page, pagereveal fires before the first frame is rendered. That is where you set names that depend on which link was clicked, or call skipTransition().

Browsers without support simply skip the animation. The page still navigates or updates as normal, which makes view transitions a safe progressive enhancement.

06

Tune it, then ship it

The default 250 ms ease suits a small change. A card that grows to fill the screen usually needs longer, and a little overshoot helps it settle. Tune both values and press Preview. The demo adds the exact CSS shown below to the page for one transition, so what you copy is what you just watched.

Tune the timing, then copy it Interactive
Press Preview to play the CSS below.
</> Your tuned timing, ready to paste.Show code
::view-transition-group(*) {
  animation-duration: 400ms;
  animation-timing-function: cubic-bezier(0.2, 0, 0, 1.15);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) {
    animation-duration: 0s;
  }
}

The readout reports the duration of every animation in the preview. The fades match the group because they inherit its duration, so one rule is enough. The overshoot only bends the group's movement and resizing. The reduced-motion block sets the duration to 0s, so the DOM still changes but nothing moves. The demos on this page follow the same idea when you ask for reduced motion: they skip the movement and keep only the fade.

</> A small helper that never throws and never blocks.Show code
function transition(update) {
  if (!document.startViewTransition) return Promise.resolve(update());
  const t = document.startViewTransition(update);
  t.ready.catch(() => {});
  return t.updateCallbackDone;
}

Accessibility needs two more habits. The snapshots are visual only. Screen readers get the DOM change right away, and focus does not move on its own, so move it in your callback the way the card demo does. Keep durations short, too. While a transition runs, the user is looking at pictures of the page, not the page itself.

Names are cheap, captures are not. Every named element is rendered into its own image. Name only what should travel, and add the names just before the transition rather than leaving hundreds in your stylesheet.

Use view transitions for changes the user caused and should be able to follow: opening an item, switching tabs, reordering a list, or moving between pages of one site. Do not use them for continuous motion such as drags or scroll-linked effects. Each transition is a one-shot snapshot, and starting a new one skips the one already running. Do not use them to cover a slow update either, because rendering is paused while your callback runs. For one element changing one property, a plain CSS transition is simpler and cheaper, as long as you avoid the transition that skips its start.

Quick answers

How do I use the View Transitions API?
Call document.startViewTransition() with a function that updates the DOM. The browser snapshots the old state, runs your function, snapshots the new state, then cross-fades between them in about 250 ms by default. Add a view-transition-name to an element and it also morphs from its old position and size to its new one.

How do I make an element morph between two states?
Give the element the same view-transition-name in the old and new state. Set the name on the old element before calling startViewTransition, then move it to the new element inside the callback, and remove it when transition.finished resolves. The browser then animates position and size while cross-fading the two snapshots. Each name must be unique at any moment.

Why is my view transition not running?
The most common cause is a duplicate view-transition-name. Under the original rule, two rendered elements sharing a name skip the whole transition: transition.ready rejects with an InvalidStateError, yet your DOM update still runs. Elements with display: none do not count. Use unique names, such as record ids, or view-transition-name: match-element, and attach a handler to ready.

Do view transitions work between separate pages?
Yes, for same-origin navigations when both pages opt in with @view-transition { navigation: auto; }. Elements with matching names then morph across the load. Chrome and Edge 126 and Safari 18.2 support it; Firefox support was still incomplete when this was written. Unsupported browsers skip the animation and navigate normally.

How do I make view transitions respect reduced motion?
Add a prefers-reduced-motion: reduce media query that sets animation-duration: 0s on ::view-transition-group(*). The DOM still changes but nothing moves. Snapshots are visual only, so screen readers get the DOM change immediately, and focus does not move by itself. Move it in your update callback.

New deep dives, in your inbox.