Browse the docs

StampCard

A loyalty punch card: a row of paper slots that fill with rubber stamps. Each stamp lands with its own seeded tilt and ink, and the newest one thunks onto the card.

Server ComponentWCAG AANew

Contributed by @luxmoncoeur. Meet the contributors

Matcha Corner
  1. Stamped
  2. Stamped
  3. Stamped
  4. Empty
  5. Empty
  6. Empty
  7. Empty
  8. Empty
5 more for a free matcha
Hojicha Club
  1. Stamped
  2. Stamped
  3. Stamped
  4. Stamped
  5. Empty
  6. Empty
Mixed inks
  1. Stamped
  2. Stamped
  3. Stamped
  4. Stamped
  5. Stamped
  6. Stamped
  7. Stamped
  8. Stamped
  9. Stamped
  10. Stamped

Change every prop live in the playground.

Props

PropTypeDefaultWhat it does
filledrequirednumber—How many slots are stamped, counted from the first. Clamped to 0…`total`.
totalrequirednumber—How many slots the card has, e.g. 8 for "buy 8, get one free".
classNamestringnoneExtra class on the card.
columnsnumberup to 6, balanced across rows (8 slots: 2 rows of 4)Slots per row.
countText(filled: number, total: number) => string"3 of 8 stamps"The count, shown on the card and read by screen readers.
idstringnoneId of the card.
ink"ink" | "tomato" | "leaf" | "ochre" | "berry" | "mixed"mixedThe ink stamps are pressed in. `mixed` gives each stamp its own seeded ink.
labelstringtitle when it's textNames the list for screen readers, before the count.
seedstring | numbergenerated from useIdStable imperfections, shared by server and client.
showCountbooleantrueShow the count ("3 of 8 stamps") on the card. It's always in the list's accessible name.
stampReactNode | ((index: number) => ReactNode)noneWhat each stamp looks like. Draw it with `currentColor` so it takes the ink. Pass a function to vary it by slot, e.g. a different last stamp. Decorative: screen readers hear the count instead. Default a ring stamp with a star.
statusText{ filled: string; empty: string; }"Stamped" and "Empty"What screen readers hear for each slot.
styleCSSPropertiesnoneInline styles on the card.
titleReactNodenoneA heading on the card, e.g. the café's name.

Use it well

DoUse it for a short run of repeat visits, like 6 to 12 drinks, and say what the card is for in the title. Pass your own stamp so it feels like your café.
Don'tUse it for long or fine-grained progress (use Progress) or for steps in a process (use StatusTimeline).

Accessibility

  • An ordered list named with the progress, like "Matcha Corner, 3 of 8 stamps"; each slot says "Stamped" or "Empty" in text, and countText and statusText change the words.
  • Stamps are decorative and hidden from screen readers, so a custom stamp never needs alt text. The count on the card is hidden too, since the list's name already says it.
  • Nothing is focusable: it's a picture of progress, not a control. A Server Component: no client JavaScript.
  • The card is paper with ink text, so it passes AA on every surface, light and dark; every stamp ink is 3:1 or more on the paper. Reduced motion stops the thunk, and forced colors draw stamps in the system text color.
Five stamps!

All aboard.

You took the whole tour. Here's Holo Pip, a foil sticker for riders who finish. It's in your playground tray now, for good.