Skip to content
caliper ui pro docs

Scratch reveal

A scratch card. Rub the foil with a finger or the mouse and it comes away under the stroke; once enough is gone the rest lifts off and what was underneath settles into place. A Reveal button does the same from the keyboard.

Pro

Scratch the foil, or reveal it.

When to use

  • Promotions, rewards and referral codes.
  • Playful reveals in onboarding or games.

When not to use

  • Information people need right away; reveal it plainly.
  • Anything that looks like gambling for money.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/scratch-reveal

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

API reference

ScratchReveal

5 props

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
children *ReactNode—What is underneath, such as a code or a prize.
label *string—Says what is hidden, e.g. "Your discount code".
coverTextstring"Scratch here"Text on the foil.
thresholdnumber0.5Share of the foil to scratch away before the rest falls away, 0 to 1.
onReveal(() => void)—

Keyboard

  • No custom key handling; Tab and the native activation keys do the work.

Accessibility

It exposes img semantics, with aria-hidden, aria-label and aria-live kept in step with state. Changes that matter are announced through a live region.

Notes for AI

Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.

/docs/components/scratch-reveal.md

The index of every part is at /llms.txt.

More in Surfaces