rogue

Shared-element transitions

Click a card — its thumbnail morphs into the detail page's hero. Hit back — the hero shrinks back into the grid. No JavaScript animation code: the browser does it all via view-transition-name.

How it works

The View Transitions API pairs elements across navigations by matching their view-transition-name. Give the same name to the source thumbnail and the destination hero — the browser computes the position and size delta and animates between them automatically.


<div style="view-transition-name: card-ember; background: #ef4444"
     class="thumbnail">div>


<div style="view-transition-name: card-ember; background: #ef4444"
     class="hero">div>

The router already wraps every client-side navigation in document.startViewTransition(), so there's nothing extra to wire up. Browsers that don't support the API (Firefox today) get instant navigation with no errors.

← Back to Showcase