StackedCards

Drag the top card away and it slips to the back of the pile. Cards.

Open playground

Brief

Define the one moment worth animating.

Block

Lay out the static state first.

Move

Add motion that carries meaning.

Ship

Respect reduced motion, then release.

About

StackedCards 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 { StackedCards } from "@ashutoshswamy/smoui" and set cards, threshold, cardClassName among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<StackedCards
  className="w-56"
  cardClassName="h-40 rounded-2xl bg-neutral-100 p-5"
  cards={[<p>Brief</p>, <p>Block</p>, <p>Move</p>]}
/>

Props 4

cards

Card contents, first is on top.

ReactNode[]
threshold

Drag distance in px that sends a card back.

numberdefault 90
cardClassName

Class on each card.

string
className

Class on the stack. Arrow keys also cycle.

string