React scratch cardScratch Card Discount Bar

React scratch card: a discount you scratch for: a strip of brushed-silver foil in the bar that scratches away under the pointer, then falls away to reveal a code you can copy.

Features

  • Brushed-silver foil drawn on a canvas, scratched away by mouse or finger
  • Once enough is gone the rest of the foil falls away
  • A copy button for the code, with a copied state
  • A "just show me" button reveals it for keyboards and screen readers
  • Still for reduced motion

Best for: Online stores and newsletters that want a discount code people work for, and remember.

Installation

npm install motion lucide-react clsx tailwind-merge

Then copy the files from the Code tab into the same paths in your project, in TypeScript or JavaScript.

Props

PropTypeDefaultDescription
labelstring-The line before the strip.
codestring-The code under the foil.
valuestring-What the code is worth.
revealLabelstring-The button that reveals it at once.
classNamestring-Classes on the bar.

FAQ

Is the Scratch Card Discount Bar free to use?

Yes. Scratch Card Discount Bar is free to copy into your own projects. Open the Code tab and paste the files into your app.

Does Scratch Card Discount Bar work with Next.js and React?

Yes. It's a React client component made for the Next.js App Router, styled with Tailwind CSS and animated with Framer Motion (the motion package).

Can I use Scratch Card Discount Bar in JavaScript instead of TypeScript?

Yes. Every file comes in TypeScript and JavaScript. Switch the language in the Code tab.

What does Scratch Card Discount Bar need installed?

motion, lucide-react, clsx, tailwind-merge, plus the shared helpers from the Installation page.

Is Scratch Card Discount Bar accessible?

Every link and button is reachable by keyboard with a visible focus ring, and the animation stays still for visitors who ask for reduced motion.