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

React
TypeScript
Tailwind CSS
Motion

Detected package dependencies: framer-motion, lucide-react.

@spectrumui/scratch-card
Coupon unlocked20% off

Drag across the card to scratch off the foil

Installation

Login to view commandCreate a free account to access the install command

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

PropTypeRequiredDescription
childrenReactNodeYesContent hidden underneath the scratch foil
onReveal() => voidNoFires once when the cleared area passes revealThreshold
onProgress(progress: number) => voidNoFires with the cleared ratio (0–1) while scratching
revealThresholdnumberNoCleared ratio (0–1) that triggers the full reveal. Default 0.5
brushSizenumberNoScratch brush diameter in pixels. Default 28
overlayLabelstringNoText printed on the foil surface
overlayColorstringNoFoil surface color
overlayLabelColorstringNoFoil label color
particleColorstringNoDust particle color
ariaLabelstringNoAccessible label for the scratch surface
revealAnnouncementstringNoAnnounced to screen readers when the content is revealed
classNamestringNoAdditional 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.

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.