Skip to content
Uxelith
Sign in
Prov1.0.0Cards

Card Stack

A deck you throw cards from: the top card leans from where you grabbed it and flies off with the speed you gave it, the rest rise to take its place, and Undo brings it back. Keys and buttons too.

Installs with Uxelith ProHow
Licence
Pro
Packages
3
Updated
18 Oct 2026
Live

Installation

Usage

example.tsx
import { CardStack } from "@/components/card-stack"

export function Picks() {
  return (
    <CardStack
      className="w-full max-w-xs"
      label="Places to visit"
    >
      <article aria-label="Lisbon" className="rounded-2xl border bg-card p-6">Lisbon</article>
      <article aria-label="Kyoto" className="rounded-2xl border bg-card p-6">Kyoto</article>
      <article aria-label="Oaxaca" className="rounded-2xl border bg-card p-6">Oaxaca</article>
    </CardStack>
  )
}

Props

PropTypeDefaultDescription
childrenReactNode—The cards, top first; give each an aria-label so it can be announced.
onSwipe(index, direction) => void—A card was thrown left or right; index is its place among children.
onUndo(index: number) => void—Undo brought a card back.
leftAction / rightActionstring"Skip" / "Keep"Labels for the two directions: buttons, stamps and announcements.
loopbooleanfalseThrown cards go to the back instead of leaving.
visiblenumber2How many cards show behind the top one.
controlsbooleantrueShow the two buttons and Undo under the stack.
emptyReactNode"That's every card."Shown when every card has gone.
labelstring"Cards"Accessible name of the stack.

Accessibility

  • The top card is focusable and announced with its position ("Desert bloom, 2 of 5"); ← and → throw it, Backspace or Ctrl/⌘+Z undo.
  • Every throw is also a real button, so touch screen-reader and switch users never need to drag.
  • Each throw and undo is announced in a polite live region ("Keep: Desert bloom").
  • Cards waiting behind are inert and hidden from assistive technology.
  • Under prefers-reduced-motion cards leave and arrive without flying; dragging still follows your hand.

Changelog

  1. v1.0.0Latest

    First release.

More in Cards

All 6 in Cards
  • CardsPro

    Compare Slider

    Two layers split by a glass handle you drag, or that follows the pointer. A press glides the divider there on a spring, a double-click sends it home; optional feathered seam, vertical split and first-view sweep.

  • CardsPro

    Morph Card

    A card that grows into its own story: the photo, eyebrow and title fly to their places, and you pull the story down to fold it back into the grid. Built on the native modal dialog.

  • CardsFree

    Pricing Card

    One plan in a pricing table, set large: a price that rolls when billing changes, a highlighted plan on a dark surface lit by your accent, and features read as included or not.