Swipe Stack

A deck of cards you can drag and fling away, with keyboard support.

no dependenciesMIT · free
ReefDrag me, or use ← →

Installation

npx shadcn@latest add https://ombakui.com/r/swipe-stack.json

Usage

import { SwipeStack } from "@/components/swipe-stack";

<SwipeStack className="w-72" onSwipe={(i, dir) => console.log(i, dir)}>
  <Card title="Reef" />
  <Card title="Swell" />
  <Card title="Coral" />
</SwipeStack>

Props

PropTypeDefaultDescription
children*ReactNode–Each direct child becomes a card.
thresholdnumber110How far (px) a card must be dragged to fly away.
visiblenumber3Number of cards visible behind the top one.
onSwipe(index: number, direction: "left" | "right") => void–Called after a card is swiped away, with its original index and direction.
classNamestring–