Expandable Cards, animated React component
A grid of story cards where picking one grows it, in one continuous spring, into a full card with the long description and a call to action while the rest of the grid sinks back; closing shrinks it home into its slot. It can open over the grid itself or in a centred dialog over the page, and the columns follow the container's width.
- Free
- Cards
- Hover
- Spring
Like Expandable Cards? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Expandable Cards stays free.
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| cards | CardItem[] | 6 sample cards | Each { id, title, description, fullDescription, category, image?, bg?, ctaText?, ctaLink? }. Without image the drawn cover in bg is used. |
| expandInto | "grid" | "viewport" | "grid" | "grid" opens a card over the grid itself; "viewport" opens it in a centred dialog over the page and locks scroll. |
| onOpenChange | (id: string | null) => void | — | Called with the card id when one opens, and null when it closes. |
| autoplay | boolean | false | Opens and closes each card in turn until someone touches the grid. |
| className | string | — | Extra classes for the root. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry
Run this once per project. It writes the Nexus UI entry into
components.jsonfor you:npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"Type it exactly as shown.
{name}is filled in by the CLI with the component you ask for, so you never replace it.
- 3
Add the component
Run this from your project root. It adds the component, the helpers it imports and its npm packages.
npx shadcn@latest add @nexus-labs/expandable-cards
- 4
Check what was added
With a project made as in the Quick Start (a
src/folder), these files land in it:components/expandable-cards/expandable-cards.tsxindex.ts - 5
Copying by hand? Skip the registry
Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that
cn()exists. Install the packages:npm install framer-motion
Then show the source and create each file at the path it gives:
- 6
Use it in a page
Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:
// src/app/page.tsx import { ExpandableCards, type CardItem } from "@/components/expandable-cards"; export default function Page() { return ( <main> <ExpandableCards /> </main> ); }
Like Expandable Cards? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Expandable Cards stays free.
About Expandable Cards
Expandable Cards are a set of cards that expand on click to reveal additional content with a smooth height animation powered by Framer Motion layout transitions. The collapsed state shows a preview snippet and the expanded state reveals full content, with surrounding cards correctly repositioned during animation. Use them for FAQs, feature breakdowns, detailed team bios, and any scenario where information should be available but not all shown simultaneously.
Good for
- FAQ and objection handling sections
- Feature detail and specification cards
- Team member bio expansions
- Product comparison detail panels