Draggable Card Stack, animated React component
A pile of photo cards you can fling: grab the top card and throw it any direction and it leans into the throw, flies off, then tucks back under the pile while the next card pops up with a little overshoot. The right arrow sends the top card away and the left arrow pulls the bottom card back; images, videos or drawn scenes all work. Also includes Spread Deck, a photo pile that deals itself into a grid, then flies one photo to the front while the rest gather in the corner. Also includes Riffle Stack, a feature deck you shuffle like real cards: riffle bows two halves apart and falls them back in clumps, cut slides the top half under.
- Free
- Cards
- Hover
- Spring
Lifts when you grab a card, swishes when you fling it and thumps when it settles back; the spread deck and riffle stack lift, swish and thump on their own moves. Sound is off on this site until you switch it on.
Draggable Card Stack
Spread Deck
Riffle Stack
Like Draggable Card Stack? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Draggable Card Stack stays free.
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Big Sur
Coast road at dusk
Lofoten
Blue hour over the bay
Kyoto
Lanterns after rain
Madeira
Above the cloud line
Wadi Rum
Sand at first light
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| cards | StackCard[] | 5 drawn scenes | Cards from top to bottom, each { id, title?, subtitle?, media?, type?: "image" | "video", bg? }. Without media a drawn scene (or bg) is shown. |
| cardWidth | number | 220 | Card width in px. |
| cardHeight | number | 296 | Card height in px. |
| borderRadius | number | 22 | Corner radius in px. |
| shadowStrength | number | 1 | Drop-shadow strength from 0 to 1. |
| stackOffset | number | 0 | Extra downward offset per card in the pile, in px. |
| maxRotation | number | 9 | Largest resting tilt of the cards underneath, in degrees. |
| depthScale | number | 0.045 | How much smaller each card underneath is (0.045 = 4.5%). |
| showOverlay | boolean | true | Title and subtitle over the top card. |
| hoverScale | number | 1.03 | Scale of the top card under the pointer. |
| onChange | (id: string) => void | — | Called with the id of the new top card. |
| hint | string | "Fling the top card. Arrow keys work too." | Caption under the stack. An empty string hides it. |
| autoplay | boolean | false | Flings the top card left and right in turn until someone touches the stack. |
| autoInterval | number | 2400 | Time between autoplay flings, in ms. |
| className | string | — | Extra classes for the root. |
| SpreadDeck.photos | SpreadDeckPhoto[] | six demo places | The photos, drawn as gradient landscapes so nothing is downloaded. Each has a title, a sub line and sky, sun and hill colours. |
| SpreadDeck.autoplay | boolean | false | Walks through pile, grid and focus by itself every 2.2 seconds until someone touches the deck. Pauses off screen and never runs under reduced motion. |
| SpreadDeck.className | string | undefined | Extra classes for the root, which fills its container up to 600px. |
| RiffleStack.cards | RiffleCard[] | eight feature cards | The deck, with an even number of cards. Each has a title, a line, two gradient colours and an SVG icon path. |
| RiffleStack.autoplay | boolean | false | Riffles and cuts the deck by itself every 2.8 seconds until someone presses a button. Pauses off screen and never runs under reduced motion. |
| RiffleStack.onShuffle | (top: string) => void | undefined | Called with the title of the card that lands on top after each riffle or cut. |
| RiffleStack.className | string | undefined | Extra classes for the root, which is 440px wide at most and scales down to fit narrow containers. |
| enableSound | boolean | true | Plays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component. |
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/draggable-card-stack
- 4
Check what was added
With a project made as in the Quick Start (a
src/folder), these files land in it:components/draggable-card-stack/draggable-card-stack.tsxindex.tsriffle-stack.tsxspread-deck.tsx - 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 { DraggableCardStack } from "@/components/draggable-card-stack"; export default function Page() { return ( <main> <DraggableCardStack /> </main> ); }
Like Draggable Card Stack? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Draggable Card Stack stays free.
About Draggable Card Stack
The Draggable Card Stack renders a pile of cards with physics-based drag and fling gestures. Cards can be picked up and thrown using Framer Motion gesture recognition, with spring physics determining throw trajectory and snap-back behavior. Releasing a card above a threshold dismisses it; below the threshold, it snaps back to the stack. Use it for onboarding card flows, testimonial carousels, or any UI that benefits from tactile, physical-feeling interaction.
Good for
- Onboarding and tutorial card flows
- Testimonial and quote carousels
- Feature discovery interactions
- Swipeable content and review decks
Draggable Card Stack questions
How far do I need to drag a card?
The top card goes to the back once it is dragged more than 120px or flung faster than 400px/s. Shorter drags spring back to the center.
Can I control the stack with the keyboard?
Yes. ArrowRight or Space sends the top card to the back and ArrowLeft brings the last card to the front. The listener is on the window, so those keys work anywhere on the page while the stack is mounted.
Does it support videos?
Set `type: "video"` on a card and pass the video URL as `media`. Videos are muted and looped, and only the top card plays.
Can the cards cycle on their own?
Turn on `autoPlay` and set `autoInterval` in milliseconds (default 3000). Other props such as `cardWidth`, `cardHeight`, `maxRotation` and `showOverlay` control the look.
Does it make sound, and how do I turn it off?
Lifts when you grab a card, swishes when you fling it and thumps when it settles back; the spread deck and riffle stack lift, swish and thump on their own moves. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.