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…

navigationclientuiv1.0.0

Preview

View Transition — live rendereffects-viewtransition--default ↗

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.

Via shadcn URL
npx shadcn@latest add https://ds.interlace.tools/r/view-transition.json
With the @interlace alias
npx shadcn@latest add @interlace/view-transition

History

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. Morph gives 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 optional types. startViewTransition does 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-transition turns 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.

Public API
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

PropTypeDescription
name*stringShared by the element on both views. Unique on the page at any moment.
disabledbooleanLeave the name off, e.g. on every card but the one being opened. @default false
children*React.ReactElement<{ style?: React.CSSPropertiesOne element that takes a `style` prop.

PageTransitionsProps

PropTypeDescription
crossDocumentbooleanTurn 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.

RuleConceptWhere
R6data-slot per part`data-slot="morph"` on the child; page-transitions
R25Client componenttransitions run in the browser
R26A11yoff under reduced motion; content never hidden

Dependencies

Base UI primitive
Native / no Base UI dependency
Lucide icons
none
NPM dependencies
none

Source

The full implementation — components/ui/effects/view-transition.tsx once installed.

198 lines · TypeScript
'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.