Card stack
Review a deck one card at a time, with a throw and an undo.
npx shadcn@latest add @silicon-ui/card-stackInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/card-stackManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/card-stack/card-stack.tsx
- components/silicon-ui/card-stack/card-stack.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
items* | T[] | — |
getKey* | (item: T) => string | — |
getLabel*A short name for the card, used in its accessible label and announcements, such as "Lisbon". | (item: T) => string | — |
renderCard* | (item: T) => ReactNode | — |
onDecide | (item: T, decision: CardDecision) => void | — |
onUndo | (item: T, decision: CardDecision) => void | — |
onReset | () => void | — |
labelsAction names for each side, used on the buttons and the stamps that appear while dragging. | { left: string; right: string } | { left: "Pass", right: "Keep" } |
outcomesPast tense of each action for announcements, such as "skipped" and "shortlisted". | { left: string; right: string } | — |
labelAccessible name for the stack. | string | "Cards" |
renderEmptyShown once every card has been decided. Receives a function that brings all cards back. | (reset: () => void) => ReactNode | — |
className | string | — |
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens