Loading preview
Animated Card
CardsA card that tilts in 3D toward the pointer with spring physics.
A scratch-off card: scratch the silver coating with a mouse or finger to reveal what's underneath.
npx shadcn@latest add @venusui/scratch-cardRun this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.
Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.
@/components/ui/scratch-card.tsxThe code behind the preview above.
scratch-card-demo.tsx
import { ScratchCard } from "@/components/ui/scratch-card"
export default function ScratchCardDemo() {
return (
<ScratchCard className="w-[min(22rem,calc(100vw-3rem))]">
<div className="flex aspect-[16/9] flex-col items-center justify-center gap-1 bg-linear-to-br from-amber-100 via-rose-100 to-violet-100 p-6 text-center text-neutral-900">
<p className="text-xs font-semibold tracking-[0.2em] text-rose-600 uppercase">You won</p>
<p className="text-4xl font-bold tracking-tight">Free shipping</p>
<p className="font-mono text-sm tracking-widest">SHIPFREE26</p>
</div>
</ScratchCard>
)
}
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | What's under the coating. |
| threshold | number | 0.55 | Share of the coating to scratch off before it clears completely. |
| brush | number | 22 | Scratch radius in px. |
| label | string | "Scratch here" | Printed on the coating. |
| onReveal | () => void | — | Called once when the content is revealed. |
All <div> props except children.
paint(). A gold coating (#fde68a to #d97706) works well for prizes.inert until revealed; a button reveals it without scratching.touch-none; make sure nothing above it captures the touch.Unknown registry "@venusui"npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.No components.json foundnpx shadcn@latest init in your project first.A card that tilts in 3D toward the pointer with spring physics.
A flight boarding pass with a perforated stub and code that flips to the fare and baggage details.
Stacked cards with the next ones peeking out; Next sends the top card to the back.