Block 297 of 297
Stacked Cards
A hand-dealt pile of cards: fling the top one aside or press next to toss it to the back while the rest spring up.
- Puck key
- StackedCardsBlock
- Export
- stackedCardsBlock
- React component
- <StackedCards />
- Files
- components/puck/stacked-cards-block.tsx
- components/puck/stacked-cards.client.tsx
- Dependencies
- gsap
- License
- MIT (GSAP has its own license)
About this block
When to use it, how to write for it, and what to change in the code.
What it's for
A deck of up to ten cards, each with a photo, tag, title, body and link, stacked with a slight hand-dealt tilt. Visitors fling the top card away by dragging or with the buttons and arrow keys, and it tucks to the back of the pile. The heading and intro sit beside the deck on desktop and above it on phones.
- Volunteer roles or ways to get involved
- Membership levels or program options to browse
- Event sessions, workshops or class offerings
Writing the content
- Use Tag for one short detail such as the time commitment, like "Saturdays · 3 hours"; it hides when blank.
- Keep Body to a sentence or two. Cards are a fixed width, so long text makes the deck tall.
- Cards allows up to 10. Four to six keeps the deck easy to cycle through.
- Deck name isn't shown but is read by screen readers, such as "Volunteer roles".
Accessibility
- The deck is a labelled carousel region; cards are groups announced by position, with titles one heading level below the section heading.
- Only the top card is reachable by keyboard, since the others are inert; arrow keys and 44px buttons cycle the deck, and a live region announces the change (WCAG 2.1.1).
- With reduced motion, cards swap with a short fade instead of a toss.
Customizing the code
- Requires gsap (with Draggable) and stacked-cards.client.tsx. TILT sets each card's resting angle and VISIBLE = 4 sets how many show in the pile.
- The toss is the rotation: dir * 18 tween in toss(); tags and links use Tailwind indigo.
Editor fields
What content editors see in the P1 sidebar when they select this block.
- Eyebrowtext
- Headingtext
- Heading levelselect
- Introtextarea
- Deck nametext
- Cardsarray