SwipeDeck

Drag the top card: it tilts, a label fades in, and past the threshold it flies off while the next rises. Undo brings the last card back from the side it left by. Cards.

Open playground

Kira Sato

Type designer, Osaka

Dune Studio

Motion design, Berlin

Marlowe Hart

Illustrator, Porto

About

SwipeDeck is a React component in the Cards category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { SwipeDeck } from "@ashutoshswamy/smoui" and set cards, threshold, onSwipe among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { SwipeDeck } from "@ashutoshswamy/smoui";

<SwipeDeck
  cards={[{ id: "1", title: "Marlowe Hart", subtitle: "Illustrator", image: "/m.jpg" }]}
  onSwipe={(card, dir) => save(card.id, dir)}
/>

Props 5

cards

The pile. Without image, a mesh cover is generated.

{ id; title; subtitle?; image?; palette?; children? }[]
threshold

Drag in px that counts as a decision.

numberdefault 110
onSwipe

Called on each decision. Arrow keys and the buttons decide too.

(card, direction: 'left' | 'right') => void
labels

Decision labels.

[string, string]default ["Nope", "Like"]
width

Card width in px. Height follows at about 1.23x.

numberdefault 260