Skip to content
IndexRequest a UIAboutContact

Swipe Decision Cards

Drag the top card left or right; stamps fade in, and releasing past the threshold flies it away. Buttons do the same.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a swipe decision card stack with three cards. Pointer-drag the top card horizontally: it follows the pointer with rotation proportional to distance (max 12 degrees), a green "KEEP" stamp fades in when dragging right and a red "SKIP" stamp when dragging left. Releasing beyond 30 percent of the card width flies the card off screen in 250 milliseconds and reveals the next card, which scales from 0.95 to 1; releasing earlier springs the card back. Provide Skip and Keep buttons and ArrowLeft and ArrowRight keys as alternatives, a counter "1 of 3", an empty state with "Start over". Announce decisions via aria-live. touch-action pan-y, prefers-reduced-motion fallback. Plain HTML, CSS and JavaScript.

About this pattern

Definition

Swipe decision cards present one item at a time. Dragging the top card sideways signals a choice, with visual stamps showing what will happen before the card is released.

Purpose & UX principles

  • Good for fast, low-stakes decisions: matching, triage, sorting.
  • Always provide buttons as an alternative for keyboard, assistive tech and people who cannot drag.
  • Give clear feedback during the drag (rotation, stamp, colour) and an easy undo for mistakes.

Interaction states

  • Idle, dragging (rotation and stamp follow), past threshold (committed), snapping back, empty deck.

Motion specification

  • Card rotates up to 12 degrees with drag distance; commit flies out in 250ms; snap-back springs over 220ms; the next card scales from 0.95 to 1.
  • Reduced motion: no rotation or fly-out; the card is simply replaced.

Responsive behaviour

  • Cards fill the width up to 280px; the swipe threshold scales with card width (about 30%).
  • Buttons stay below the stack at 44px tall.

Code

HTML
<div class="bx"><div class="deck" id="deck" tabindex="0" aria-label="Card deck, use arrow keys to decide"></div><div class="btn"><button id="no" type="button" aria-label="Skip">✕ Skip</button><button id="yes" type="button" aria-label="Keep">♥ Keep</button></div><p class="out" id="out" aria-live="polite"></p></div>

Related patterns

Swipe Carousel

↗
Swipe CarouselGestures & Touch

Swipe to Delete

↗
Swipe to DeleteGestures & Touch

Stacked Cards

↗
Stacked CardsCards & Containers