> Documentation index: https://web.dev/articles/llms.txt

![James Stuckey Weber](https://web.dev/images/authors/jamesstuckeyweber.jpg) James Stuckey Weber [GitHub](https://github.com/jamesnw) [Bluesky](https://bsky.app/profile/jamessw.com) [Homepage](https://oddbird.net/authors/james)


Published: November 19, 2026

<br />

The View Transition API increase the polish and usability of your Single Page
Application (SPA) by adding cues about how content is repositioned as a user
goes through your application.

Humans perceive subtle and continuous changes, like scrolling through a page, or
a button's hover effect, as connected motion. Complete changes, like navigating
to a new page, are seen as switching to a new context. Changes that are
somewhere in between can be jarring.

And yet these non-subtle, non-complete changes are common on the web. We
navigate between pages on a site, and the navigation header is in a slightly
different place, or the text of a clicked link is now the header, or an image
that was a thumbnail is now the hero.

With view transitions, you can push these changes out of the in-between space.
You can smooth out the transitions to show continuity, or make it more drastic
to help the user switch contexts.

Aside: [Modern Web
Guidance](https://developer.chrome.com/docs/modern-web-guidance) has guides for
implementing view transitions in SPAs---[Directional Navigation
Transitions](https://github.com/GoogleChrome/modern-web-guidance-src/blob/main/guides/ui-behaviors/directional-navigation-transitions/demo.html)
and [Same Document
Transitions](https://github.com/GoogleChrome/modern-web-guidance-src/blob/main/guides/ui-behaviors/same-document-transitions/demo.html).
Read more about [getting started with Modern Web
Guidance](https://developer.chrome.com/docs/modern-web-guidance/get-started).

## Where should I use view transitions?

When thinking about how to incorporate view transitions into your site, first
compare the before and after views. To do this, load both states in separate
browser windows, or before a site is implemented by comparing wireframes or
mockups.

What parts of the page are in both views? Some of these may be static, like a
site header or footer. Others may be related to this specific transition, like
an article's title or photo.

![A two page wireframe. Left: a large image, a header with the text 'common name', and followed by a subtitle, 'scientific name'. Right: All elements from the left are present in a different layout, with paragraphs of filler text.](https://web.dev/static/articles/designing-view-transitions/image/fig-1.png)

In this wireframe, there are 3 shared items---a photo, common name, and scientific
name. The positions and styles change, but they represent the same content.

What is the conceptual feeling of the move between the two views? Is it drilling
down, going forwards and backwards, reading the next page? Does the action map
to something from the physical world, like paging through a newspaper or turning
a book over to read the back cover?

![A web navigation wireframe. Left: a card titled Lessons, listing lessons 1 through 4. Right: A lesson card with filler representing lesson content, and lesson navigation links. Arrows indicate clicking lesson 1 on the left, leads to the card on the right. Clicking the lessons navigation on the right leads back to the left card.](https://web.dev/static/articles/designing-view-transitions/image/fig-2.png)

In this wireframe, "Lesson 1" and "Lessons" are shared content. But the shared
content isn't as static as the prior example---the link becomes the heading, and
the heading becomes a link. This isn't multiple views of the same content, but
rather a replacement of the page's content.

## Whole page versus partial transitions

View transitions can be applied to the entire page, or specific elements. You
likely will only want to use a movement transition on specific elements, or on
the entire page, and not both.

### Whole page transitions

Use a move transition on the whole page to give hints about the conceptual
navigation. For instance, move content in from the right to show forward
navigation, and then from left to right to show backward navigation. This helps
the user understand they are back where they started.
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/LEyVzyK?height=384&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;"></iframe>

In this demo, the user is moving through an ordered series of lessons, which is
analogous to a real-world textbook. From the main page, the user would expect to
turn forward to an individual lesson, and so we slide the lesson in from the
right side. In an individual lesson, the user can take three different actions.
They can go to the next lesson---which uses the same transition---sliding in from
the right. Alternatively, the user can go back to the list of lessons or back to
the previous lesson, in which case we reverse the transition, and slide the
current lesson back out to the right.

Taken together, these transitions help keep the user oriented as they navigate
through the lessons. Learn how to have different [transitions based on
context](https://web.dev/learn/css/view-transitions-spas#different_transitions_based_on_context),
using View Transition Types and `:active-view-transition-type()`.

### Transitioning specific elements

Use move transitions on specific elements when you want to communicate that
something represents the same item, or to draw their attention to an element.
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/GgmJMMZ?height=520&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;"></iframe>

In this demo, you move between two views of the same item---in this case, a bird.
Because of that, the image, common name, and scientific name are in both views.
Adding a transition between the views provides a cue that the user is not
transitioning to a different kind of bird, and helps them retain the context
while the view changes.

> [!NOTE]
> **Objective:** Learn how to [transition specific
> elements](https://web.dev/learn/css/view-transitions-spas#transitioning_specific_elements) with the `view-transition-name` property.

When you transition specific elements, the whole page still has a default fade
in/fade out transition. In most cases, this works well---it smooths the change to
the background, without drawing attention away from the elements that move.

Another use case for transitioning specific elements is when you're navigating
from a list of items to a detail page for a single one. While you could use a
whole page transition, you could also choose to transition the item's title and
thumbnail into their larger positions on the detail page. Which you choose is up
to you- ask if it's more important that the user understands the context of the
navigation within the larger app, or if they retain the context of the selected
item between views.

## Fallback Strategies

View transitions are a progressive enhancement, meaning that while they are nice
to have, they are not required for your site to function or for your content to
be accessible. To more easily support browsers that don't support the View
Transition API, abstract out the function that moves content between views. In
this example, it's called `updateDOM()`. If `document.startViewTransition` is
not defined, it will fall back to calling `updateDOM()` directly, rather than as
the `startViewTransition()` callback.

```javascript
document.startViewTransition?.(updateDOM) || updateDOM();
```

Or, if you need to set other iew transition parameters, you can use a more
explicit `if`/`else` block.

```javascript
if(!document.startViewTransition){
  updateDOM();
} else {
  document.startViewTransition({
    update: updateDOM,
    types: [direction]
  });
}
```

This helps make sure the new content is available without the View Transition
API, and makes sure future changes stay in sync.

## Implementation

To use the View Transition API on your SPA, use the Modern Web Guidance guide,
or refer to [View transitions for SPAs](https://web.dev/learn/css/view-transitions-spas.md.txt). You
can use this checklist to make sure your implementation works well:

- Do the transitions match the feel of your site? Do they give the user hints about the change, or do they distract from the content?
- Make sure that for each `view-transition-name`, there is exactly one before the transition, and exactly one after the transition.
- Remove dynamic `view-transition-name` values after the transition completes, using a `transition.finished.finally(()=>{})` callback.
- Check for content being skewed during a transition- you may need to adjust the element's aspect ratio, apply `width: fit-content` for text, or set the `object-fit` property for images. See [View transitions: Handling aspect
  ratio changes](https://jakearchibald.com/2024/view-transitions-handling-aspect-ratio-changes/) for more tips. Limit the number of elements being transitioned, both for performance and the user experience
- Test with `prefers-reduced-motion` to make sure that transitions are disabled or reduced
- Consider what should be focused after a transition