View Transitions API: a complete overview

How the View Transitions API works: transitions between pages with one CSS rule, shared elements, transitions within a page, browser support, three tested examples, mistakes and rules.

Stack and technologies Updated

In short

The View Transitions API is a browser feature that animates the change from one state of a page to another — or from one page to the next. The browser takes a snapshot of the old state, renders the new one and plays a smooth transition between them: by default a cross-fade, and with a few lines of CSS a photo flies from the catalogue into the product page, a header stays still and the content slides. For a multi-page site it takes one CSS rule and no JavaScript; within one page it is one function call. Where the browser does not support it, the site simply works without animation.

View Transitions at a glance

The main facts in one table — what the API does, its two kinds and what happens without support.

What it is
A browser API for animated changes between states and pages
Two kinds
Within one page — startViewTransition(); between pages — the CSS rule @view-transition
How it works
A snapshot of the old state, the new state, an animation between them in pseudo-elements
By default
A cross-fade of the whole page
Shared elements
The same view-transition-name on both sides — the element moves from place to place
Without support
An ordinary change without animation — nothing breaks
Standard
CSS View Transitions Module, Levels 1 and 2, W3C

Features and browser support

Eight parts of the API with their purpose and support. For the newest ones, check support before use — without it they are simply ignored.

FeatureWhat forSupport
startViewTransition() a transition within one page all modern
view-transition-name an element that moves on its own all modern
::view-transition-old/new your own animation of the old and new state all modern
@view-transition transitions between pages of a site Chrome, Edge, Safari
pageswap, pagereveal events to tune a transition between pages Chrome, Edge, Safari
view-transition-class one animation for a group of elements new — check
transition types different animations forward and back new — check
match-element automatic names for many elements new — check

Where transitions help: 8 cases

A transition is worth adding where it explains what happened — where the element went and where it came from.

CaseKindWhat moves
Catalogue → product between pages the photo grows into the large one
Blog list → article between pages the cover and the title
Any page of a site between pages the content; the header stays
Catalogue filter within a page cards to their new places
Tabs within a page the underline and the content
Steps of a form within a page the step slides out, the next slides in
Light and dark theme within a page the new theme opens from the button
Screens of a Telegram Mini App within a page the screen as in a native app

Pros and cons of View Transitions

The browser does the hard part of the animation itself. Both the gains and the limits come from that.

Pros · 5

  • One line for a whole site

    @view-transition turns every click between pages into a smooth change.

  • No library

    Not a kilobyte of JavaScript for transitions between pages.

  • An app feeling without an SPA

    The site stays ordinary pages, simple for search engines and fast to load.

  • Safe to add

    Without support the site just works without animation.

  • Animations in CSS

    The look of a transition is set by ordinary keyframes and pseudo-elements.

Cons · 4

  • Uneven support between pages

    Transitions between pages do not work in every browser yet.

  • Snapshots are images

    When the size changes, the text in a snapshot stretches and needs tuning.

  • The page is not clickable meanwhile

    While a transition plays, clicks go to its layer — long animations get in the way.

  • One site only

    Transitions between pages work only within one origin.

What View Transitions look like: 3 examples

A transition between pages, a shared photo and a filter within one page. All three were run in a browser on a local server.

Transitions between pages

One rule turns them on, two pseudo-elements set the look, and a reduced-motion branch removes them completely.

transitions.css
/* Both pages include this file: a click on a link becomes a smooth transition */
@view-transition {
  navigation: auto;
}

/* The whole page: the old one fades out, the new one rises slightly */
::view-transition-old(root) {
  animation: 0.2s ease-in both fade-out;
}
::view-transition-new(root) {
  animation: 0.3s ease-out both rise-in;
}
@keyframes fade-out {
  to { opacity: 0; }
}
@keyframes rise-in {
  from { opacity: 0; translate: 0 1rem; }
}

/* Whoever turned motion off in the system gets an instant change */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

A shared photo

The same name on two pages — and the thumbnail flies into the product photo.

catalog.html
<!-- Catalogue: each thumbnail gets its own name -->
<a href="/catalog/oak-table">
  <img src="/img/oak-table.webp" alt="Oak table" width="320" height="240"
       style="view-transition-name: product-a100">
</a>

<!-- Product page: the photo has the same name —
     the browser flies the thumbnail into the large photo -->
<img src="/img/oak-table.webp" alt="Oak table" width="960" height="720"
     style="view-transition-name: product-a100">

A filter within a page

The cards move to their new places; in a browser without support the filter works instantly.

filter.js
// Each card gets its own name once — the browser tracks every card separately
document.querySelectorAll('.card').forEach((card, i) => {
  card.style.viewTransitionName = `card-${i}`;
});

// Filtering the catalogue without a reload: cards slide to their new places
function applyFilter(category) {
  const update = () => {
    for (const card of document.querySelectorAll('.card')) {
      card.hidden = category !== 'all' && card.dataset.category !== category;
    }
  };
  // No support — the filter simply works without animation
  if (!document.startViewTransition) {
    update();
    return;
  }
  document.startViewTransition(update);
}

Common mistakes with View Transitions

  1. Two elements with one name

    If a name repeats on a page, the browser skips the whole transition.

  2. Slow animations

    A transition longer than half a second makes every click feel slow.

  3. No reduced-motion branch

    People who turned motion off in the system still get it.

  4. Animating everything

    Dozens of moving elements turn a transition into noise; one or two are enough.

  5. Expecting it to hide a slow server

    The transition starts only when the new page is ready — a slow page stays slow.

  6. A stretched snapshot

    An element changing proportions distorts; it is fixed in ::view-transition-old and -new.

6 rules for transitions in a real project

  1. 01

    Start with one line

    @view-transition { navigation: auto; } gives the whole site a soft change at once.

  2. 02

    A name for the header

    A header with its own name stays still while the content changes.

  3. 03

    Only key elements

    The photo, the title, the cover — what the eye follows.

  4. 04

    Unique names from data

    The name is built from the product or article id — it is the same on both pages.

  5. 05

    0.2 to 0.4 seconds

    Long enough to notice, short enough not to wait.

  6. 06

    Check, then call

    Within a page — always a branch for browsers without startViewTransition.

Questions about View Transitions

What is the View Transitions API?

A browser feature that animates the change between states of a page or between pages.

Does it need JavaScript?

Between pages — no, one CSS rule is enough; within one page — one function call.

Which browsers support it?

Transitions within a page — all modern ones; between pages — Chrome, Edge and Safari, others are catching up.

What do other browsers show?

An ordinary change of page without animation — nothing breaks.

Can it replace a single-page application?

For many sites, yes: smooth transitions were the main reason for an SPA, and now ordinary pages have them.

Does it affect SEO?

No: the pages stay ordinary HTML, the transition is only a few lines of CSS.

Do frameworks support it?

Yes, many routers call it themselves — in Astro, for example, it is built in.

Online form

Transitions
for your site

I add page transitions with CSS and the View Transitions API — without heavy libraries and without turning the site into a single-page application. Tell me about the project — I answer within one working day.

Or write to [email protected]