Valyro Русская версия

Scratch Reveal

Scratch off a cover to reveal text or a picture. Free, MIT · Interactive blocks › Stickers, tickets and boards

A card under a coat that the reader scratches off with a finger or the mouse; past the threshold the rest disappears. The Show button reveals it at once. The coat is a visual effect, not protection: the content is in the page, and whether a prize is due is the app's decision.

Installation

npx valyro-cli@latest add scratch-reveal
npx shadcn@latest add https://valyro.xyz/r/scratch-reveal.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { ScratchReveal } from 'valyro-ui';

Props

PropTypeDefault
children *ReactNodeWhat the cover hides: text, a picture or a card. It cannot be focused until revealed.
coverScratchCoverLook of the coat.
brushSizenumber36Brush diameter in CSS px. Default 36.
thresholdnumber0.6Share of the card that must be cleared to reveal it all. Default 0.6.
revealedbooleanControlled revealed; use with onRevealedChange.
defaultRevealedbooleanfalseInitial revealed when uncontrolled.
onRevealedChange(revealed: boolean, reason: ScratchRevealReason) => voidA request to reveal (scratch, button) or cover again (reset). Controlled cards follow revealed.
onReveal(reason: 'scratch' | 'button') => voidOnce per cycle, when the threshold is reached or the button is pressed; not when revealed is set from outside.
onProgressChange(progress: number) => voidCleared share 0…1 while scratching, at most about ten times a second.
resetKeystring | number0A new key clears the scratches of a covered card. It does not cover a revealed one (revealed={false} does).
resettablebooleanfalseOffer a button that covers the card again once revealed. Default false.
disabledbooleanfalseNo scratching and no button.
labelsPartial<ScratchRevealLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

  • Peel Sticker — A sticker you peel back by its corner to reveal what is under it
  • Tear-off Ticket — A ticket whose stub tears off along the perforation
  • Split-Flap Board — Mechanical departure board: only the changed characters flip
  • Swipe Action Card — Swipe a card sideways to reveal its actions
  • Feature Hotspots — Numbered points on an image that open a note about each detail
  • Exploded Layers — Prepared image layers pulled apart with captions
  • Prediction Card — The reader guesses first, then sees the answer and the explanation
  • Detail Dial — Choose how deep an explanation goes: short, detailed or full
  • Version Scrubber — Step through prepared versions of a design with one slider
  • Page Minimap — Schematic map of a long page with the visible area
  • Sticker Board — A free composition of photos, stickers and notes to move and rotate
  • Lasso Select — Drag a rectangle to select a group of cards

Previous: Peel Sticker · Next: Tear-off Ticket · All Interactive blocks