Interaction
Flip Card Stack
A draggable card stack where the top card snaps to the back after a threshold drag. Framework-agnostic Custom Element.
- gsap
Preview
01
Velocity
Gesture-friendly stack with a tactile top-card swap.
02
Depth
The stack keeps scale and rotation offsets while you drag.
03
Motion
Drag me and toss me to the back of the queue.
Drag the top card past the threshold and it snaps to the back of the stack with GSAP-driven transforms.
Attributes
Installation
pnpm dlx shadcn@latest add https://motion-kit-astro.vercel.app/r/flip-card-stack.json Usage
---
import "@/components/motion-kit/flip-card-stack-element.ts";
---
<motion-flip-card-stack
stack-offset="8"
stack-rotation="-10"
drag-threshold="80"
duration="0.3"
ease="power2.out"
class="inline-grid relative w-[320px] h-[480px]"
>
<div class="flip-grid-item w-full h-full bg-white rounded-2xl p-6">
<h2>Card 1</h2>
</div>
<div class="flip-grid-item w-full h-full bg-slate-50 rounded-2xl p-6">
<h2>Card 2</h2>
</div>
<div class="flip-grid-item w-full h-full bg-white rounded-2xl p-6">
<h2>Card 3</h2>
</div>
</motion-flip-card-stack> API Reference
| Attribute | Type | Default |
|---|---|---|
stack-offset Vertical offset (in pixels) between stacked cards. | number | 8 |
stack-rotation Rotation angle (in degrees) for each card in the stack. | number | -10 |
drag-threshold Distance (in pixels) the card must be dragged before it snaps to the back. | number | 80 |
duration Animation duration in seconds. | number | 0.3 |
ease easing function for card animations. | string | "power2.out" |