Skip to main content
Clever Ops

View Morph

A shared-element morph kit for React on the View Transitions API, cards morph into detail sheets and back, instant fallback where unsupported. Focus-managed, reduced-motion honest.

Preview & code

Loading View Morph preview

Installation

pnpm dlx shadcn@latest add @cleverui/view-morph

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { ViewMorph } from '@/components/blocks/view-morph'
Exampletsx
import { ViewMorph } from '@/components/blocks/view-morph'

export default function ViewMorphDemo() {
  return (
    <ViewMorph
      eyebrow="Lab · Shared elements"
      heading="The card becomes the page."
      items={[
        {
          id: 'geometry',
          kicker: 'Geometry',
          title: 'One name, two states',
          body: 'The selected card and its detail sheet share a view-transition-name for the duration of the swap, the browser interpolates position, size, and radius between the two layouts. No measured FLIP math, no absolutely-positioned clones.',
          meta: 'view-transition-name: vm-shared',
        },
        {
          id: 'fallback',
          kicker: 'Fallback',
          title: 'Instant when unsupported',
          body: 'Browsers without startViewTransition get an immediate state swap. The interaction contract is identical, the animation is a bonus layer, never a requirement.',
          meta: 'progressive enhancement · no polyfill',
        },
        {
          id: 'focus',
          kicker: 'Focus',
          title: 'Focus rides the morph',
          body: 'Opening moves focus to the close control; closing returns it to the card that sent you. Escape works from anywhere in the sheet.',
          meta: 'wcag 2.4.3 focus order',
        },
        {
          id: 'reduced',
          kicker: 'Reduced motion',
          title: 'Respects the setting completely',
          body: 'prefers-reduced-motion switches the kit to instant swaps, the View Transitions API is never engaged, not merely shortened.',
          meta: 'prefers-reduced-motion: reduce',
        },
        {
          id: 'react',
          kicker: 'React',
          title: 'flushSync, the documented recipe',
          body: 'React commits the next state synchronously inside the transition callback so the browser snapshots exactly the before and after frames.',
          meta: 'react-dom · flushSync',
        },
        {
          id: 'ssr',
          kicker: 'SSR',
          title: 'Server-safe by construction',
          body: 'Support detection happens after mount; the server render is the plain grid with a neutral capability line, no hydration drift.',
          meta: 'no window at render',
        },
      ]}
    />
  )
}

API reference

ViewMorph accepts the following props.

PropTypeDefaultDescription
eyebrowstring
headingstring
items*ViewMorphItem[]3–8 cards; each morphs into its detail sheet

…plus everything from React.HTMLAttributes<HTMLElement>: className, event handlers, aria attributes and the rest pass straight through.

Referenced types

Typestsx
export interface ViewMorphItem {
  id: string
  kicker?: string
  title: string
  body: string
  /** mono footer line in the expanded sheet */
  meta?: string
}

Frequently asked questions

How do I install the View Morph component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/view-morph`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does View Morph require?

View Morph uses lucide-react on top of React and Tailwind CSS. You don't need to install it manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme View Morph to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services