Stacked Cards
Collapsed it is the front card plus a sliver of each card behind; open, the cards lay out at their real heights. Dismiss with the close button or a sideways flick. Can rotate on a timer.
The decision inside it
Opens on keyboard focus too
Tabbing into the pile fans it out, so every card and its close button can be reached without a mouse.
When to use it
Use Stacked Cards for a few recent items that should take little room until someone looks: notifications, tips, recent uploads. For a full list use a plain list.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Layro's Stacked Cards for this.
Install it: npx shadcn@latest add @layro/stacked-cards
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/stacked-cards.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @layro registry with your CLI token: see the Namespaced tab.
Usage
import { StackedCards } from "@/components/ui/stacked-cards";
export function RecentNotifications({ notes, read }: { notes: { id: string; text: string }[]; read: (id: string) => void }) {
return (
<StackedCards
dismissible
onDismiss={read}
items={notes.map((n) => ({ id: n.id, label: n.text, content: <p className="p-4 pr-10 text-sm">{n.text}</p> }))}
/>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
itemsrequired | StackedCardItem[] | — |
visible | number | Cards showing behind the front one when stacked. Default 3 in total. |
autoRotate | number | false | Milliseconds between moving the front card to the back, or false. Default false. |
dismissible | boolean | A close button on each card, and flick to dismiss. Default false. |
onDismiss | (id: string) => void | — |
offset | number | Pixels each card behind peeks out. Default 12. |
scaleFactor | number | How much smaller each card behind is. Default 0.05. |
gap | number | Gap between cards when open, in pixels. Default 10. |
expandOnHover | boolean | Fan out on hover and focus. Default true. |
label | string | The pile's name for screen readers. Default "Notifications". |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themeStates
All of them are drawn by the component. None is left for you to design.
- Stacked
- Fanned out
- Dismissing
- Rotating
- Empty
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances
Lifetime access
Every component, and everything we ship next.
- All 232 components, source included
- Every template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.