Scratch cards
A coating in any finish over whatever an element holds, scratched off with a coin's ragged edge.
scratch coats an element, whatever it holds, for scratching off. The coating is a finish (steel, a scratch card's silver, unless said) in coat's colour, with print written on it, and its corners are the element's own.
import { Scratch } from "@cesarvenzac/stickers/react";
<Scratch
print="Scratch here"
onReveal={() => setWon(true)}
className="grid h-40 w-72 place-items-center rounded-xl"
>
You won
</Scratch>;The pointer scratches where it goes, brush pixels wide, with a coin's ragged edge; flakes of coating fall as it goes, and the coating's edge casts a hair of shadow on what it uncovers. onScratch is told the share scratched so far. Past revealAt (half, unless said; 1 never), the rest crumbles away, and onReveal is called.
Without React
import { scratch } from "@cesarvenzac/stickers";
const card = scratch(element, { finish: "holo", revealAt: 0.6 });
card.reveal(); // all at once
card.reset(); // coated againFor everyone
Until it's revealed, the card is a button named by label, and what's under the coating isn't read; Enter or Space reveals it. Under reduced motion no flakes fall and it's revealed at once.