Scratch Card

Rub the cover with a mouse or finger to uncover the prize.

no dependenciesMIT · free

20% OFF

Code: OMBAK20

Scratch with your mouse or finger.

Installation

npx shadcn@latest add https://ombakui.com/r/scratch-card.json

Usage

import { ScratchCard } from "@/components/scratch-card";

<ScratchCard onReveal={() => track("revealed")}>
  <p className="text-4xl font-bold">20% OFF</p>
</ScratchCard>

Props

PropTypeDefaultDescription
children*ReactNode–The prize underneath.
coverColorstring"#94a3b8"Color of the scratch-off layer.
coverLabelstring"Scratch here"Text printed on the cover.
brushnumber22Brush radius in px.
revealAtnumber0.5Share of the card (0–1) that must be cleared to reveal it all.
onReveal() => void–Called once the card is fully revealed.
classNamestring"h-40 w-72"Size classes.