Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

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

1 / 5Fling the top card. Arrow keys work too.

Props

PropTypeDefaultWhat it does
cards5 drawn scenesCards from top to bottom, each { id, title?, subtitle?, media?, type?: "image" | "video", bg? }. Without media a drawn scene (or bg) is shown.
cardWidth220Card width in px.
cardHeight296Card height in px.
borderRadius22Corner radius in px.
shadowStrength1Drop-shadow strength from 0 to 1.
stackOffset0Extra downward offset per card in the pile, in px.
maxRotation9Largest resting tilt of the cards underneath, in degrees.
depthScale0.045How much smaller each card underneath is (0.045 = 4.5%).
showOverlaytrueTitle and subtitle over the top card.
hoverScale1.03Scale of the top card under the pointer.
onChange—Called with the id of the new top card.
hint"Fling the top card. Arrow keys work too."Caption under the stack. An empty string hides it.
autoplayfalseFlings the top card left and right in turn until someone touches the stack.
autoInterval2400Time between autoplay flings, in ms.
className—Extra classes for the root.
SpreadDeck.photossix demo placesThe photos, drawn as gradient landscapes so nothing is downloaded. Each has a title, a sub line and sky, sun and hill colours.
SpreadDeck.autoplayfalseWalks 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.classNameundefinedExtra classes for the root, which fills its container up to 600px.
RiffleStack.cardseight feature cardsThe deck, with an even number of cards. Each has a title, a line, two gradient colours and an SVG icon path.
RiffleStack.autoplayfalseRiffles 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.onShuffleundefinedCalled with the title of the card that lands on top after each riffle or cut.
RiffleStack.classNameundefinedExtra classes for the root, which is 440px wide at most and scales down to fit narrow containers.
enableSoundtruePlays 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. 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 creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry

    Run this once per project. It writes the Nexus UI entry into components.json for 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.

  1. 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
  2. 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.tsx
    index.ts
    riffle-stack.tsx
    spread-deck.tsx
  3. 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:

  4. 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.

Guides