Swipe Cards

A draggable card stack where each swiped card cycles to the back with smooth momentum-based animations.

One Piece

One Piece

Attack on Titan

Attack on Titan

Naruto

Naruto

Demon Slayer

Demon Slayer

Jujutsu Kaisen

Jujutsu Kaisen

My Hero Academia

My Hero Academia

Fullmetal Alchemist

Fullmetal Alchemist

Hunter x Hunter

Hunter x Hunter

Installation

$ npx shadcn@latest add https://akshitr.com/r/swipe-cards.json

Usage

import SwipeCards from "@/components/swipe-cards";
 
const cards = [
  { id: 1, title: "Santorini, Greece", url: "/images/santorini.jpg" },
  { id: 2, title: "Kyoto in Autumn", url: "/images/kyoto.jpg" },
];
 
export default function SwipeCardsDemo() {
  return <SwipeCards cards={cards} />;
}

Component API

SwipeCards

PropTypeDefaultDescription
cardsCardData[]Array of card data to render in the stack.
className?stringAdditional classes applied to the root element.

CardData

PropTypeDefaultDescription
idnumberUnique identifier for the card.
urlstringImage URL rendered as the card background.
titlestringLabel rendered at the bottom of the card.

Notes

  • Swipe threshold is 120px or a velocity of 500px/s — whichever is hit first.
  • On a confirmed swipe the card animates to ±340px in the drag direction before the stack reorders, keeping the visual stack consistent without any flashes.
  • dragElastic={1} means the card tracks the pointer with zero resistance — it follows your finger exactly.