Stack Shuffle

A deck of cards that deals itself as you scroll.

Category
Creative
Access
Free with an account
Source
134 lines · one file
States
4 drawn

The decision inside it

The last card stays

The deck deals down to its final card and stops, so the section ends on content, never on an empty table. Scroll per card is fixed, so a short deck and a long one feel the same speed. Reduced motion shows the cards as a plain list.

When to use it

Use Stack Shuffle for a deck of cards dealt one at a time as people scroll: testimonials, steps, photos.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Stack Shuffle for this.
Install it: npx shadcn@latest add @liro/stack-shuffle
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/stack-shuffle.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/deck.tsx
import { StackShuffle } from "@/components/ui/stack-shuffle";

const cards = ["It paid for itself in a week.", "It just fits.", "Every state is there."].map((q) => (
  <figure key={q} className="h-full rounded-2xl border bg-card p-6 text-lg">{q}</figure>
));

export function Deck() {
  return <StackShuffle cards={cards} />;
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
cardsReact.ReactNode[] YesThe cards, top first.
stridenumber NoScroll per card, in px. Default 320.
containedboolean NoScroll inside its own box rather than with the page.
heightnumber NoHeight of the visible stage, in px. Default 440.

Dependencies

npm packages

clsxframer-motiontailwind-merge

Liro foundations, installed alongside it

liro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Stacked
  • Dealing
  • Last card
  • Reduced motion

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances