Morphing dialogPro
A card that morphs into a dialog: cover, title and frame fly to their new places.
When to use
- Galleries, collections and feature cards where the detail view should feel connected to the card.
When not to use
- Forms and confirmations: use a dialog.
- Lists of dozens of cards on low-end devices.
Installation
Usage
Import it from @/components/ui/morphing-dialog after installing.
example.tsx
import { MorphingDialog } from "@/components/ui/morphing-dialog";
export function Collection() {
return (
<MorphingDialog title="Aurora" subtitle="24 pieces" image="/covers/aurora.jpg">
<p>Soft gradients and glass surfaces…</p>
</MorphingDialog>
);
}API reference
MorphingDialog
A card button that expands into a modal dialog with shared-element transitions.
| Prop | Type | Default | Description |
|---|---|---|---|
| title / subtitle | string | – | Shown on the card and in the dialog. |
| image | string | – | Cover image URL. |
| colors | [string, string] | – | Gradient cover when there's no image. |
| children | ReactNode | – | Content shown only when open. |
Keyboard interactions
| Keys | Action |
|---|---|
| EnterorSpace | Open |
| Esc | Close |
| TaborShift+Tab | Cycle focus inside the dialog |
Accessibility
- A real modal: aria-modal, labelled by the title, focus trapped and returned to the card.
- Page scroll is locked while open.
Motion
- Frame, cover, title and subtitle share layout IDs and fly between card and dialog (spring, 500ms).
- Body text fades up after the morph.
- Instant under reduced motion.
Responsive behavior
- Cards up to 272px; the dialog is up to 512px and scrolls inside on short screens.
Performance
- Dialog content mounts only when open.
Notes for AI
- Each instance gets its own layout IDs, so many can share a page.
This page as Markdown, for assistants and coding agents:
/components/morphing-dialog/markdownThe full library index for assistants is at /llms.txt.
Lode222 doc pagesllms.txt