The card that becomes the page
26 October 2026 2 min read
A list card opens a detail page. Cut or morph? The same flow built twice, with the View Transitions API and a fallback that costs nothing.
- Motion
- Navigation
- CSS
You tap a card and the page is simply different. Nothing is wrong with that, but the eye has to work out where the thing it tapped went. A transition that carries the card into the page answers that question without a word.
The new view replaces the old
Cut
The card becomes the page
Morph
Open an item on each side. The left one cuts. On the right the image and the title travel from the card to their place in the detail view, so you can follow them.
What it takes
The View Transitions API takes a snapshot of the page before a change, applies the change, takes a snapshot after, and animates between the two. For elements that exist in both, give them the same view-transition-name and the browser moves and resizes one into the other.
const t = document.startViewTransition(async () => {
open = index;
await tick(); // let the framework update the DOM first
});
.vt-img { view-transition-name: card-img; }
.vt-title { view-transition-name: card-title; }
::view-transition-group(card-img),
::view-transition-group(card-title) {
animation-duration: 420ms;
}
The rule that bites
A name may exist only once on the page at a time. Three cards with the same name means the transition is skipped. So the name is given to the card that was tapped, just before the change, and removed afterwards. The demo does exactly that.
The fallback is the feature
If document.startViewTransition does not exist, or the person asked for less motion, the change simply happens. The code path is the same as the left side: one state change. Nothing is polyfilled and nothing breaks, which is why this is safe to ship today.
const canMorph = 'startViewTransition' in document
&& !matchMedia('(prefers-reduced-motion: reduce)').matches;
In SvelteKit
For real page navigation, wrap it in onNavigate. It runs before the new page renders, and returning a promise keeps the old page until the snapshot is taken.
onNavigate((navigation) => {
if (!document.startViewTransition) return;
return new Promise((resolve) => {
document.startViewTransition(async () => {
resolve();
await navigation.complete;
});
});
});
Where it goes wrong
- Duplicate names, covered above. Lists need a name per item or one name moved to the active item.
- Long transitions. Past about 400 ms it stops feeling like help and starts feeling like waiting.
- The first paint of the detail page. If its image loads late, the morph lands on an empty box. Reserve the size.
- Focus. Moving focus to the new page heading is still your job. The animation does not do it.
Related
- Scroll animations that survive a frozen page The same scroll effect, once with a scroll listener and once with CSS scroll-driven animations. Freeze the page and compare what keeps moving.
- Springs keep their momentum, Bézier curves don't A cubic-bezier is a fixed path through time. A spring is a rule. Only the rule survives being interrupted.