View Transition
The browser's View Transitions API, made safe to reach for: a card grows into its detail page, a list reorders in place, and a page change cross-fades instead of blinking. Interlace adds only what the API leaves to every app: a fallback where it is…
Preview
Rendered from the story the storybook (a11y) CI gate runs axe against — the preview can't show something that hasn't been verified.
Install
Two equivalent paths — the URL works in any shadcn-CLI setup; the alias works once you've registered @interlace in your components.json.
npx shadcn@latest add https://ds.interlace.tools/r/view-transition.jsonnpx shadcn@latest add @interlace/view-transitionHistory
This component is at v1.0.0, first shipped in @interlace/ui 2.0.0. The version is stamped as a banner into the file the install writes, so the copy in your tree says which one you have — compare it with the number above before deciding whether to re-run the install.
@interlace/ui 2.0.01 entry
- Addedminor
View transitions, made safe to reach for.
Morphgives its one child a view-transition name (any string, cleaned into a valid identifier), so a card's image and the detail page's hero with the same name morph into each other: the card grows into its page.useViewTransition()runs a React state change inside a transition, flushed so the browser captures the new view, with optionaltypes.startViewTransitiondoes the same for code outside React.PageTransitions(once, in the root layout) is a server-safe<style>: the old page fades out, the new one rises in by half a rem, and@view-transitionturns it on between documents;pageTransitionsCss()returns the same CSS. Where the browser has no View Transitions the update simply runs, and under reduced motion there is no transition at all. Opacity and transform only.
Import
7 named exports — pull the parts you need.
import { Morph, PageTransitions, pageTransitionsCss, startViewTransition, supportsViewTransitions, useViewTransition, viewTransitionName } from '@/components/ui/effects/view-transition';Anatomy
Extracted from the primitive's JSDoc header. The source is the only documentation that can't drift.
startViewTransition(update, options?) (plain function: any framework) useViewTransition() → (update, options?) => void, with flushSync Morph name="card-42" (gives its one child a view-transition-name) PageTransitions (a <style>: page changes between documents)
API reference
Parsed from the type declarations in the source — the same file the install writes into your tree, so this table can't drift from the component you get.
MorphProps
| Prop | Type | Description |
|---|---|---|
| name* | string | Shared by the element on both views. Unique on the page at any moment. |
| disabled | boolean | Leave the name off, e.g. on every card but the one being opened. @default false |
| children* | React.ReactElement<{ style?: React.CSSProperties | One element that takes a `style` prop. |
PageTransitionsProps
| Prop | Type | Description |
|---|---|---|
| crossDocument | boolean | Turn on transitions between documents (multi-page sites). @default true |
| page | 'rise' | 'fade' | 'none' | The page's own fade and rise. 'none' leaves only named elements moving. @default 'rise' |
Accessibility
Every story for this component is rendered headlessly and checked with axe-core (wcag2aa, wcag22aa, best-practice, ACT) on every PR. That gate has no continue-on-error, so what ships has zero known violations.
What follows is what static analysis can see. Axe cannot press a key and never sees an overlay open, so the operable-without-a-mouse claim lives in Behavior instead, where the keyboard path is replayed step by step.
- Focus + keyboard behaviour
- Native element semantics — no interaction layer to get wrong.
- Focus ring (WCAG 2.2 SC 2.4.13)
- Not focusable — no focus indicator required.
- Reduced motion
- Animation is gated on prefers-reduced-motion.
- ARIA in the source
- None — semantics come from the element or the Base UI primitive rather than hand-written ARIA.
Examples
2 more states from the same story file.
R-rule compliance
Every primitive in @interlace/ui models to the portable 26-rule floor enforced by the componentApi ESLint preset. The cells below pin exactly where each rule applies in this file.
| Rule | Concept | Where |
|---|---|---|
| R6 | data-slot per part | `data-slot="morph"` on the child; page-transitions |
| R25 | Client component | transitions run in the browser |
| R26 | A11y | off under reduced motion; content never hidden |
Dependencies
- Base UI primitive
- Native / no Base UI dependency
- Lucide icons
- none
- NPM dependencies
- none
- Registry dependencies
Source
The full implementation — components/ui/effects/view-transition.tsx once installed.
'use client';
import * as React from 'react';
// @interlace/view-transition v1.0.0 — Interlace design system.
// Docs, props and live preview: https://ds.interlace.tools/c/view-transition
// What changed since: https://ds.interlace.tools/c/view-transition#history
// Generated banner — keep it, the upgrade diff reads this version.
/**
* @interlace/ui — View transitions: startViewTransition, useViewTransition, Morph, PageTransitions
*
* The browser's View Transitions API, made safe to reach for: a card grows
* into its detail page, a list reorders in place, and a page change
* cross-fades instead of blinking. Interlace adds only what the API leaves
* to every app: a fallback where it is missing, nothing at all under reduced
* motion, React state flushed inside the transition, and names that are
* always valid.
*
* ## Anatomy
…178 more lines…Registry JSON
The raw registry record — what the shadcn CLI fetches.