Pro
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.
pnpm dlx shadcn@latest add @caliper/scratch-revealWhen to use
Use it for
- Promotions, rewards and referral codes.
- Playful reveals in onboarding or games.
Skip it when
- Information people need right away; reveal it plainly.
- Anything that looks like gambling for money.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- Enough is enough
- Half the foil scratched away is treated as done, so nobody has to clear every corner.
Usage
- Hidden until revealed
- The prize is kept from assistive technology and the keyboard until it is revealed, and Reveal is always there.
Installation
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.
Usage
Import it from your copy of the source. The example behind the preview comes with the source.
import { ScratchReveal } from "@/components/ui/scratch-reveal"
The worked example comes with Pro
The 28-line example behind the preview opens here, ready to copy.
- 602 Pro parts, blocks and page templates, all with source
- $199 once, with a year of updates. What you have stays yours
- A full refund within 14 days if it is not for you
API reference
ScratchReveal
component
Also accepts the native props of its root element and a ref.
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.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.
Related
- Ink spoilerText kept under a fine drifting ink until it is asked for. Press it and the ink blows outward from where you pressed while the words come through; press again to cover them.
- Celebration burstOne small burst of confetti when a real milestone completes: the first deploy, a finished setup, a paid invoice. Skipped under reduced motion; the words say what happened.
- Ticket stubA ticket with a perforated stub. Checking in tears the stub off along the perforation, so used is something you can see on the ticket and not only read. The tear is the feedback; the plain text line on the ticket is the record.