DevTools Logo

CSS View Transitions API Animation Lab

CSS View Transitions API Animation Lab

Generate view-transition CSS for the root or a named element, plus the document.startViewTransition call.

Runs in your browser
Try an example

Transition settings

Live demo

Current view

Run live demo calls document.startViewTransition when the browser supports it.

Generated CSS

fade · root pair · 350ms
Support (MDN / caniuse, reviewed 2026-11): same-document transitions in Chrome and Edge 111+, Safari 18+, Firefox 144+. Cross-document transitions: Chrome and Edge 126+, Safari 18.2+, not Firefox. Always feature-detect document.startViewTransition.
@keyframes vt-fade-root-old {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes vt-fade-root-new {
  from { opacity: 0; }
  to { opacity: 1; }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 350ms;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
}

::view-transition-old(root) {
  animation-name: vt-fade-root-old;
}

::view-transition-new(root) {
  animation-name: vt-fade-root-new;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

Examples

Root fade with custom duration

Input
buildViewTransitionCss({ preset: "fade", duration: "400ms", timingFunction: "ease-in-out" })
Output
@keyframes vt-fade-root-old/new + animation-duration: 400ms;

The default root name pairs ::view-transition-old(root) with ::view-transition-new(root) under one shared timing block.

Named morph pair

Input
buildViewTransitionCss({ transitionName: "card", preset: "morph" })
Output
::view-transition-old(card) + ::view-transition-new(card) with clip-path

A valid identifier emits both pseudo-element rules keyed to the card transition with inset clip-path keyframes.

About this tool

CSS View Transitions Builder emits crossfade-style page-transition CSS with buildViewTransitionCss(options): pick a preset (fade, slide, scale, flip, morph), a duration ("350ms" default, numbers become ms), a timing function, and a transition name (root by default) to receive paired old/new keyframes, shared duration/timing/fill rules, and per-side animation-name selectors.

Names and timing validate strictly: validateViewTransitionName accepts root or CSS identifiers (letters, digits, hyphens, underscores), the timing pattern accepts linear/ease variants plus steps() and cubic-bezier(), and anything invalid flips valid to false with a message while the emitted CSS sanitizes back to safe fallbacks (root for the name, ease-in-out for timing).

Each preset ships fixed keyframe bodies — slide translates ±24 px, scale zooms .92↔1.08, flip rotates ±90° in 800 px perspective, morph insets a rounded clip-path, fade only fades — and identical options always produce byte-identical CSS, so output is safe to snapshot.

How to use this tool

  1. Choose a preset

    Select fade, slide, scale, flip, or morph — slide keyframes carry translateX, morph carries clip-path, and every preset pairs an old (exit) with a new (enter) animation.

  2. Name the transition

    Set transitionName to a valid CSS identifier (or root); names with spaces fail validation and the CSS falls back to the root transition.

  3. Set duration and timing

    Pass duration as "600ms"/"0.6s" or a millisecond number, plus a timing function like ease-in-out or cubic-bezier(...) — the duration lands verbatim in animation-duration.

Use cases

Scaffolding SPA route transitions

Generate the keyframes and pseudo-element selectors for document.startViewTransition-driven navigation.

Theming per-element transitions

Assign named transitions (card, panel) with distinct presets so shared elements morph while the backdrop fades.

Validating transition config

Catch illegal names and timing functions via the valid flag before pasting CSS into production.

Common mistakes

Mistake:Using display names with spaces as transition names.

Fix:Only CSS identifiers validate — "card detail" fails and the CSS silently targets root, so slugify names to card-detail first.

Mistake:Passing a free-form timing string like "wat".

Fix:Only keyword easings, steps(), and cubic-bezier() validate; anything else flips valid to false and falls back to ease-in-out.

Mistake:Expecting slide to move elements across the screen.

Fix:Slide offsets are a subtle ±24 px fade-assist, not a full off-canvas traversal — write custom keyframes for hero-style travel.

Frequently asked questions

What does this tool do?

It generates paired old/new keyframes plus the ::view-transition-old()/::view-transition-new() selectors for the fade, slide, scale, flip, or morph preset, with your duration and timing function wired in — deterministically, so identical options give byte-identical CSS.

Why did my custom name fall back to root?

Transition names must be root or valid CSS identifiers — "card detail" with a space fails validation, so the tool marks the build invalid and emits the CSS against root. Slugify it to card-detail to get a named old/new pair.

Is my transition configuration uploaded or stored?

No. Preset selection, validation, and CSS assembly run entirely in your browser — nothing leaves your device.

What does the slide preset actually animate?

A subtle ±24 px translateX with a fade — old content exits left while new content enters from the right. It is a fade-assist, not a full off-canvas traversal; write custom keyframes if you need hero-style travel.

References & standards