Skip to content

Scratch Card

Pro

A card with a foil that people scratch off with a finger or a mouse to show a prize. Enter or Space plays a scratch and shows it.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · Pro license

Playground

Loading the preview

Props

Needs your Pro API key in GELATIN_UI_PRO_TOKEN. Set it up

Pro itemAPI key required

Scratch Card needs a Pro API key

Try the live preview for free. With Pro, the add command above puts the source in your project.

Files it adds
33
More Pro items, one API key
+327
Your coding agent runs it
1 cmd

$79$129once, for life

Already have Pro? Sign in to set up your API key.

Put the prize and the foil inside ScratchCardSurface. The label names the foil.

reward-card.tsx

ScratchCard

<div>
PropTypeDefaultDescription
childrenReactNode—
foil"hatch""holographic""metallic"—The look of the foil: hatch (default, diagonal lines), metallic, or holographic.
thresholdnumber—The scratched share (0.2 to 1) past which the rest of the foil falls away. Default 0.6.
brushSizenumber—The brush width in CSS px. Default 32.
revealedboolean—The content shows (controlled).
defaultRevealedboolean—The content shows at first (uncontrolled).
onRevealedChange—Called when the reveal starts (true) and after a reset (false).
disabledboolean—No scratch and no key reveal.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

ScratchCardSurface

<div>
PropTypeDefaultDescription
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

ScratchCardContent

<div>
PropTypeDefaultDescription
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

ScratchCardFoil

<button>
PropTypeDefaultDescription
driverRef—Drives a scratch from code (DragDriver, no item): a staged scene or a test presses the foil at a viewport point, carries the brush, and lets go. The cuts, the dust, and the reveal work as for a finger, and no pointer event is sent.
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
className—CSS class applied to the element, or a function that returns a class based on the component's state.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

ScratchCardLabel

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

ScratchCardKeyHint

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

ScratchCardDescription

<p>
PropTypeDefaultDescription
...props<p> attributes—Every other attribute goes to the <p>, with a ref.
  • Put the prize in ScratchCardContent and the label in ScratchCardFoil, both inside ScratchCardSurface.
  • Put ScratchCardKeyHint in the foil to show "Press Enter to reveal" while the foil has keyboard focus.
  • Lower threshold and raise brushSize for a small card on a phone.
  • Read onRevealedChange to save that the prize was seen, and pass revealed to keep it open next time.
  • For text that people only must click to show, use a Spoiler.
  • For a password or a key that people show and hide, use a Password Field.
TabMoves to the foil. The ScratchCardKeyHint shows under the label.
EnterPlays a scratch sweep and shows the prize. The focus goes to the prize.
SpacePlays a scratch sweep and shows the prize. The focus goes to the prize.

The foil is a Base UI Button named by ScratchCardLabel and described by ScratchCardDescription. A screen reader click plays the sweep and shows the prize.

Until the reveal, the content is inert and aria-hidden, so no one reads or tabs into the prize. After a key reveal, the content takes the focus, so the focus never drops to the page.

A disabled card is dimmed and the foil is not a tab stop.

The foil sets touch-action: none, so a finger scratches and does not scroll the page. The brush ring shows only for a mouse or a pen.

Key sweep
sheet · 600ms · ease-panel (0.2, 0.4, 0.2, 1), a brush crosses the card in three lines
Foil falls away
overlay · 200ms · the foil fades and grows, with a burst of dust
Prize
popup · 150ms · the prize grows from 96% to 100%
Label
fade-exit · 90ms · the label fades when the scratch starts
  1. AddedScratch Card.
Open the release