---
title: "Swipe Deck"
description: "A stack of cards to swipe left or right, like a dating or discovery app. The top card follows the pointer and tilts from where it was grabbed, with Like and Pass stamps fading in; past the threshold or on a fast flick it flies off with the release speed, while the cards behind lean forward and settle into place. Undo brings the last card back in from the side it left, and pass, undo and like buttons do the same from the keyboard."
category: "Blocks"
publishedAt: "2026-12-04"
updatedAt: "2026-12-04"
documentation: "https://beui.dev/components/blocks/swipe-deck"
markdown: "https://beui.dev/components/blocks/swipe-deck.md"
license: "MIT"
---

# Swipe Deck

> A stack of cards to swipe left or right, like a dating or discovery app. The top card follows the pointer and tilts from where it was grabbed, with Like and Pass stamps fading in; past the threshold or on a fast flick it flies off with the release speed, while the cards behind lean forward and settle into place. Undo brings the last card back in from the side it left, and pass, undo and like buttons do the same from the keyboard.

## Install

```bash
npx shadcn@latest add @beui/swipe-deck
```

## Dependencies

- `@floating-ui/dom`
- `clsx`
- `lucide-react`
- `motion`
- `react`
- `react-dom`
- `tailwind-merge`

## Usage

```tsx
"use client";

import { SwipeDeck, type SwipeDeckItem } from "@/components/motion/swipe-deck";

type Stay = SwipeDeckItem & {
  place: string;
  price: string;
  image: string;
  alt: string;
};

const stays: Stay[] = [
  {
    id: "lake-cabin",
    label: "Lake Cabin",
    place: "Lofoten, Norway",
    price: "$180 night",
    image:
      "https://images.unsplash.com/photo-1470770841072-f978cf4d019e?auto=format&fit=crop&w=720&h=960&q=80",
    alt: "A lakeside cabin beneath mountains, reflected in the water",
  },
  {
    id: "studio-loft",
    label: "Studio Loft",
    place: "Lisbon, Portugal",
    price: "$95 night",
    image:
      "https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=720&h=960&q=80",
    alt: "Bright open-plan studio with long desks and plants",
  },
  {
    id: "concrete-house",
    label: "Concrete House",
    place: "Valencia, Spain",
    price: "$240 night",
    image:
      "https://images.unsplash.com/photo-1511818966892-d7d671e672a2?auto=format&fit=crop&w=720&h=960&q=80",
    alt: "Sculptural architecture",
  },
  {
    id: "valley-retreat",
    label: "Valley Retreat",
    place: "Dolomites, Italy",
    price: "$160 night",
    image:
      "https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=720&h=960&q=80",
    alt: "Open landscape",
  },
];

export function SwipeDeckPreview() {
  return (
    <SwipeDeck
      items={stays}
      sound
      renderCard={(stay) => (
        <div className="relative size-full">
          <img
            src={stay.image}
            alt={stay.alt}
            draggable={false}
            className="size-full object-cover"
          />
          <div className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-3 pt-10 text-white">
            <p className="font-semibold text-sm">{stay.label}</p>
            <p className="text-xs text-white/80">
              {stay.place} · {stay.price}
            </p>
          </div>
        </div>
      )}
    />
  );
}
```

## API Reference

### SwipeDeck

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `items` | `T[]` |  | Yes | Every card, top of the deck first. Swiped cards stay in the list and are skipped. |
| `renderCard` | `(item: T) => ReactNode` |  | Yes | The card's content. Fills the card frame. |
| `value` | `SwipeDeckDecision[]` |  | No | Swipes made so far, oldest first, for controlled use. |
| `defaultValue` | `SwipeDeckDecision[]` | `[]` | No | Swipes already made when uncontrolled. Default: [] |
| `onValueChange` | `((value: SwipeDeckDecision[]) => void)` |  | No | Called with every swipe made so far after a swipe or an undo. |
| `onSwipe` | `((item: T, direction: SwipeDirection) => void)` |  | No | Called with the card and direction when a card is swiped away. |
| `onUndo` | `((item: T, direction: SwipeDirection) => void)` |  | No | Called with the card and the direction it had left in when an undo brings it back. |
| `threshold` | `number` | `110` | No | Drag distance that swipes a card away on release (px). A fast flick needs less. Default: 110 |
| `visible` | `number` | `3` | No | Cards drawn in the stack, the top card included. Default: 3 |
| `controls` | `boolean` | `true` | No | Show the pass, undo and like buttons under the deck. Default: true |
| `leftIcon` | `ReactNode` |  | No | Icon for the pass button. Default: an X icon |
| `rightIcon` | `ReactNode` |  | No | Icon for the like button. Default: a heart icon |
| `empty` | `ReactNode` |  | No | Shown once every card is swiped. Default: the "No more cards" message |
| `sound` | `boolean` | `false` | No | Play a whoosh on each swipe and a lift on undo. Default: false |
| `aria-label` | `string` |  | No | Accessible name for the deck. Default: "Card deck" |
| `labels` | `Partial<{ label: string; card: string; left: string; right: string; undo: string; swipedLeft: string; swipedRight: string; restored: string; empty: string; }>` |  | No | Override any built-in string. |
| `className` | `string` |  | No | Classes merged onto the root element. |
| `cardClassName` | `string` |  | No | Classes merged onto each card frame. |

## Types

### SwipeDeckDecision

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The `id` of the swiped card. |
| `direction` | `SwipeDirection` | Yes | Which way the card was swiped. |

## About Swipe Deck

Swipe Deck is a swipeable card stack for React, built with Framer Motion and Tailwind CSS. The top card follows the pointer and tilts from where you grabbed it on a soft spring, so it wobbles like a held card when you stop or change direction, and stretches less the further you pull it up or down. Like or Pass stamps fade in as it nears the threshold. Release past the threshold, or flick it fast, and the card flies off with the speed you threw it; let go early and it bounces back to the center. The cards behind lean forward while you drag and settle into place once it goes. Undo brings the last card back in from the side it left, even mid-throw. You render each card's content, and the deck reports every swipe through onSwipe and a controllable value list. Set sound for a whoosh on each swipe and a lift on undo.

### When to use it

- A dating, discovery or matching app asks people to say yes or no to one profile at a time.
- A shopping or travel app lets people sort products or places into liked and passed.
- A review queue, flashcard drill or triage flow needs quick one-card-at-a-time decisions.

### Accessibility

Pass, Undo and Like are real buttons with tooltips, so every swipe works from the keyboard or a switch. The top card is a group named with its position, such as Card 2 of 4, and the cards behind it are hidden from assistive technology and cannot be focused. A polite live region announces each result, such as Liked Lake Cabin or Brought back Lake Cabin. With reduced motion the card still follows your finger, but it does not tilt, wobble or bounce, swiped cards fade out in place and undone cards fade back in.

### FAQ

**How do I make Tinder-style swipe cards in React?**

Install the block and pass items, each with an id and a label, plus renderCard to draw each card. Handle the result in onSwipe, which gets the card and "left" or "right".

**Can I keep the swipes in my own state?**

Yes. Pass value and onValueChange. The value is the list of swipes made so far, oldest first, each with the card id and direction. Removing the last one is an undo.

**How do I change how far a card has to move?**

Set threshold in pixels. A fast flick needs less distance, so short throws still count.

## Source

- Registry detail: https://beui.dev/r/swipe-deck
- Raw source: https://beui.dev/r/swipe-deck/raw
- GitHub: https://github.com/starc007/ui-components
