Expandable Card
NewA card that grows out of the grid into a full panel and shrinks back on close. FLIP animation, no libraries.
Installation
$ pnpm dlx shadcn@latest add @synccn/expandable-cardFirst time in this project? Connect synccn with one command.
Usage
import { ExpandableCard } from "@/components/ui/expandable-card";<ExpandableCard title="Saved views" preview={<Card />}>Details…</ExpandableCard>API reference
Generated from the component's TypeScript types, so it always matches the code.
ExpandableCard
A card that grows out of its spot in the grid into a full panel, and shrinks back on close (a FLIP animation, no libraries). Escape, the close button or the backdrop close it.
- previewrequired
React.ReactNodeThe card as it sits in the grid.
- titlerequired
stringHeading of the open card, also its accessible name.
- children
React.ReactNodeExtra content shown only when open.
- className
stringExtra classes for the card in the grid.
- panelClassName
stringExtra classes for the open panel.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for X
Keyboard
- EnterorSpaceOpen the card
- TaborShift+TabMove focus; it stays inside while open
- EscClose
Accessibility
- The open card is a modal dialog that traps focus and returns it to the card when closed. Reduced motion skips the animation.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: dialog
- ARIA attributes: aria-expanded, aria-haspopup, aria-label, aria-modal
- Keeps keyboard focus inside while open, and returns it when closed
- Closes with Escape
- Stops the page behind from scrolling while open
- Respects the reduced motion setting
- Shows a visible focus ring for keyboard users