Skip to content

No.132 · Cards

Fan Deck

A stack of cards that behaves like a hand of them: at rest a tidy pile; reach for it and it fans out in an arc so you can see every card, the one you're over lifting; pick one and it comes up out of the hand and tucks in on top. Swipe or use the arrow keys to deal through.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Paper

Build a deck of five itinerary cards (5:7, 250px, art on top, mono meta, serif title, a blurb shown only on the top card) that behaves like a hand of cards. Each card is a button absolutely stacked in the same box; its place in the pile i (0 = top) is a CSS variable, z-index n − i. Rest: a loose pile — translateY(5px·i) and a small alternating rotation (±1.5°·i). When the pointer enters the deck (or focus enters it) it fans: every card rotates by (0.5 − i/(n−1))·46° (top card to the right, deeper cards to the left so their corners and titles show) around a transform-origin far below the cards (50% 160%), so they spread on an arc like a hand; the card under the pointer lifts (translateY −48px, scale 1.03, a deeper shadow), the ones behind dim slightly. Transitions are 520ms with a slight overshoot. Picking a card (click, or Enter on the focused top card's neighbours via the arrows): it lifts clear of the hand (translateY −110px, −4°, z-index on top, 230ms), the order changes so it's on top, and it tucks back down into the pile while the others re-fan. Swipe left/right on the deck (≥40px within 600ms) or arrow keys deal to the next/previous card; ← → buttons under the deck do the same, with a polite live "Wadi Shab · 2 of 5". The top card is the only tabbable one and is aria-current; others are labelled "Bring … to the top". Themes: paper and night. Reduced motion: instant reordering, no transitions. Selected variant — Paper (paper): Palette for this theme (Paper): --card #fbf8f2; --edge rgb(0 0 0 / 0.08); --ink #1e1a14; --muted rgb(30 26 20 / 0.55). Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "paper". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Hover to fan the cards, click one to bring it to the top; swipe, arrow keys or the ← → buttons to deal through them. Motion: Fan and settle 520ms with a slight overshoot; lift 230ms then tuck. Accessibility: A labelled section of buttons; only the top card is in the tab order, arrows deal, and the current card is announced politely. Responsive behavior: Cards are min(250px, 62vw) wide; the fan's spread is angular, so it fits narrow screens. Touch: Swipe across the deck to deal; tap a card to bring it up. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Hover to fan the cards, click one to bring it to the top; swipe, arrow keys or the ← → buttons to deal through them.
Motion
Fan and settle 520ms with a slight overshoot; lift 230ms then tuck.
Accessibility
A labelled section of buttons; only the top card is in the tab order, arrows deal, and the current card is announced politely.
Responsive
Cards are min(250px, 62vw) wide; the fan's spread is angular, so it fits narrow screens.
On touch
Swipe across the deck to deal; tap a card to bring it up.