Scratch Card
Overview
A scratch-to-reveal card that wipes away a canvas foil overlay on drag.
This media component is intended for interfaces that need a scratch-to-reveal card that wipes away a canvas foil overlay on drag, landing pages, and portfolio pages. Its implementation is provided as editable source so the final behavior and styling stay inside your project.
Technologies
Detected package dependencies: framer-motion, lucide-react.
Drag across the card to scratch off the foil
Installation
Usage
The live preview and its Code tab above are the working example for this component. Copy the example after installation, then provide the required values from its TypeScript signature.
Props
| Prop | Type | Required | Description |
|---|---|---|---|
children | ReactNode | Yes | Content hidden underneath the scratch foil |
onReveal | () => void | No | Fires once when the cleared area passes revealThreshold |
onProgress | (progress: number) => void | No | Fires with the cleared ratio (0–1) while scratching |
revealThreshold | number | No | Cleared ratio (0–1) that triggers the full reveal. Default 0.5 |
brushSize | number | No | Scratch brush diameter in pixels. Default 28 |
overlayLabel | string | No | Text printed on the foil surface |
overlayColor | string | No | Foil surface color |
overlayLabelColor | string | No | Foil label color |
particleColor | string | No | Dust particle color |
ariaLabel | string | No | Accessible label for the scratch surface |
revealAnnouncement | string | No | Announced to screen readers when the content is revealed |
className | string | No | Additional classes accepted by the component source. |
Use cases
- interfaces that need a scratch-to-reveal card that wipes away a canvas foil overlay on drag
- landing pages
- portfolio pages
Features
- Copy-paste source that remains in your repository
- TypeScript source included with the component
- Tailwind CSS classes editable in the component source
- Animation implemented with Motion
- Reduced-motion handling present in the source
Accessibility
- The source includes ARIA attributes or roles; preserve them when customizing the component.
- The source includes keyboard event handling; verify it alongside pointer behavior.
- The source checks reduced-motion preferences or includes motion-reduce styles.
- Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.
Customization
- Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
- Use the documented className surface for local layout adjustments, then edit the source for structural changes.
- Adjust Motion transitions in the source and keep the reduced-motion behavior aligned with the final interaction.
Related components
Topic guides
See how this component fits into broader interface patterns, implementation decisions, and working examples.
Scratch Card FAQ
Is Scratch Card free to use in commercial projects?
Yes. The public Scratch Card source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.
How do I install Scratch Card?
Run npx shadcn@latest add @spectrumui/scratch-card. The page also exposes the source for manual installation.
Does Scratch Card require Motion?
Yes. Motion usage was detected in the documented source or registry dependencies for Scratch Card.
Does Scratch Card use shadcn/ui or Radix UI?
No shadcn/ui or Radix UI dependency was detected in the documented Scratch Card source.
Can I use Scratch Card in Next.js?
The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.
What accessibility checks should I run for Scratch Card?
The source includes ARIA markup, keyboard handlers, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.