Expandable Card
ProA card that morphs into a dialog using shared layout animations.
Installation
pnpm dlx shadcn@latest add @viewport/expandable-card
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| title* | string | — |
| subtitle | string | — |
| media | React.ReactNodeVisual shown at the top of the card, shared between both states. | — |
| children* | React.ReactNodeContent shown only when expanded. | — |
| className | string | — |
Accessibility
- Behaves as a modal: focus moves in, Tab is contained, Escape closes.
- Focus returns to the card on close.
- Becomes a bottom sheet on phones.