Code
In context
Install · Free Web Component
One file, no dependencies. Aurora preset, every other option included. Host it yourself so your visitors never load anything from our servers.
The shadcn command adds a typed React wrapper for you. Using the file directly? Custom elements work in React as-is; for type checking add:
Pro · React + TypeScript Pro
One payment of $4.99, yours forever. Use it in unlimited personal and commercial projects; no resale.
- React component that covers any node, with a ref for reset, reveal and scratchLine, TypeScript types and the full source
- Sunset, Mint and Mono foils, plus custom foils from Brand Fit
- The vanilla Web Component with every foil, a demo page, README and license
Attributes & props
| Name | Type | Default | Description |
|---|---|---|---|
| children | any content | — | What is under the foil. The card takes its size from the content, or set a width / height on the element. |
| brush | number (px) | 38 | Diameter of the brush. The cursor is a ring of the same size. |
| threshold | 0..1 | 0.55 | Share of the area that has to be cleared before the rest dissolves and reveal fires. |
| label | string | 'Scratch to reveal' | Hint pressed into the foil; also the accessible name. An empty string draws nothing. |
| radius | number (px) | 20 | Corner radius of the card. |
| revealed | boolean | false | Forces the content open (for example for someone who already claimed the prize); removing it puts the foil back. |
| theme | 'light' | 'dark' | 'light' | A bright pearl foil or a dark graphite one. |
| sound | boolean | off | Fine ticks while scratching and a glass chime on reveal. Also on for everything inside an element with data-ui-sound="on". |
| reveal / progress | events | — | reveal fires once when the card opens; progress fires while scratching with detail.value from 0 to 1. |
| reset() / reveal() / scratchLine(x0, y0, x1, y1) | methods | — | Put the foil back, open the card, or scratch a line from script (coordinates are 0..1 of the width and height). |
| tint Pro | 'aurora' | 'sunset' | 'mint' | 'mono' | object | 'aurora' | Colours of the foil and of the falling flakes, or a custom tint. Free build ships Aurora only. |
The foil is drawn in code on a canvas: a pearl body, three pools of colour from the tint, an engraved weave, grain and glitter, so there is nothing to download and it stays sharp on any screen. Scratches are kept in a separate mask, which lets the card resize or change theme without losing them. Until it opens the card is one focusable button (Enter or Space reveals it) and the content is hidden from assistive technology and from Tab. Only the foil has touch-action: none, so the page still scrolls from anywhere else. The foil hides the content visually, not in the page source: do not treat it as a secret. With reduced motion there are no flakes and the foil fades out. No WebGL.
More components
- Frost Card
- Holo Card
- Lens Compare
- Beam Border
- Spotlight Card
- Tide Slide
- Pearl Code
- Ink Sphere
- Stream Text
- Pearl Dial
- Nova Rating
- Pearl Check
- Pearl Input
- Glass Toast
- Pearl Select
- Glass Sheet
- Pearl Accordion
- Glass Tip
- Pearl Calendar
- Glass Nav
- Pearl Tabs
- Glass Command
- Halo Avatar
- Pearl Steps
- Pearl Skeleton
- Pearl Table
- Pearl Chip
- Pearl Empty
- Roll Counter
- Glass Marquee
- Reveal Text
- Mesh Gradient
- Silk Waves
- Dot Field
- Plasma Orb
- Voice Wave
- Plush Buddy
- Gummy Agent
- Glass Tabbar
- Glass Menu
- Pearl Pricing
- Glass Bento
- Quote Wall
- Glass Cta
- Magnet Button
- Glass Sidebar
- Pearl Pagination
- Pearl Breadcrumb
- Glass Dock
- Pearl Slider
- Pearl Segmented
- Liquid Metal Button
- Mercury Orb
- Prompt Input
- Voice Orb
- Aurora Ring
- Glass Toggle
- Firefly Button
- Pearl Button
- Pearl Loader
- Alien Face
- Prism Button
- Liquid Carousel
- Orbit Carousel
- Deck Carousel