Scratch-off
Markup where the component goes, CSS in your stylesheet, script before </body>. In Vue, Svelte or Angular, call initCardScratch(el) on the mounted element instead.
Paste into Claude, ChatGPT or Cursor after filling in {{USER_STACK}}, {{USER_STYLING}} and {{USER_CONSTRAINTS}}. Neutral keeps the greys you see here; Match my project asks the model to map them onto your own colour tokens.
Install with shadcn
Needs a free account token. Get a token
npx shadcn@latest add @movin/card-scratchAbout this component
A scratch card. Drag across the silver foil (a canvas) to erase it with destination-out strokes while flakes fall from the scratch; once about half is gone the rest dissolves and the prize pops. Keyboard users get a Reveal button, and Scratch again resets it.
Triggers
- Click
- Card
- Fill
- Mouse tracking
Techniques
- Event position
- Keyframes
- State machine
Difficulty
Intermediate
Accessibility
Keyboard and screen readers
A Reveal button (visible on focus) reveals the prize without scratching, and becomes Scratch again afterwards. The prize text is in the DOM, not the canvas.
Reduced motion
No flakes fall and the prize appears without the pop.
Use it in anything you build, commercial and client work included. Licence