# Scratch Card

> Scratch off the foil to reveal what is underneath.

Rub with a mouse, pen or finger; once enough is gone the rest falls away. For giveaways, discount codes, onboarding surprises and spoilers.

- Family: Originals
- Plan: Creative. Included with Creative.
- Requires: React, Tailwind CSS v4 and the motion package
- Page with a live preview: https://galactrex.com/ui/scratch-card/
- Licence: https://galactrex.com/ui/license/

## Install

```sh
npx @galactrex/ui login   # once, with an API key from https://galactrex.com/account/
npx @galactrex/ui add scratch-card
```

It installs to `components/galactrex/scratch-card.tsx`, with the shared motion helpers beside it. First time in a project: `npx @galactrex/ui init` (setup guide: https://galactrex.com/docs/ui-components-setup/).

## Usage

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

<ScratchCard onReveal={claim}>
  <p className="p-8 font-mono text-2xl">GLTX-20</p>
</ScratchCard>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` | — | What is underneath. |
| `cover` | `string` | `"Scratch here"` | Text printed on the foil. |
| `threshold` | `number` | `0.55` | Share cleared before the foil falls away. |
| `brush` | `number` | `34` | Scratch width in px. |
| `onReveal` | `() => void` | — | Called once when revealed. |
| `className` | `string` | — | Extra classes for the outer element. |

## Variants

- **Promo code.** A code underneath, revealed with a single gesture.
- **Spoiler.** Hide an answer until someone wants it.

## Accessibility

- The foil is a button: Enter or Space reveals everything at once.
- Content underneath is in the document, so screen readers can reach it.

## Motion

- Canvas erasing under the pointer; the foil fades and blurs away once revealed.
