- Docs
- Components
- 3D & Tactile
- Tactile & Physics
- Scratch Card
A metallic foil card you scratch to reveal a code
| Name | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | What sits under the foil. Replaces the built-in title and code. |
title | string | "40% off" | Large line revealed under the foil. |
code | string | "SPRING40" | Code shown under the title. Click it after the reveal to copy it. |
label | string | "Scratch to reveal" | Hint printed on the foil. An empty string hides it. |
width | number | 360 | Card width in pixels. The card shrinks to fit narrower spaces. |
height | number | 224 | Card height in pixels. The ratio is kept when the card shrinks. |
radius | number | 18 | Corner radius of the card. |
finish | "silver" | "gold" | "holographic" | "graphite" | "silver" | Look of the foil. The light bands slide with the pointer. |
brushSize | number | 22 | Radius of the scratch in pixels. |
threshold | number | 0.6 | Share of the foil scratched away before the rest clears by itself. |
flakes | boolean | true | Small foil flakes tumble off as you scratch. |
shimmer | boolean | true | Tilts the light across the foil now and then until someone scratches. |
trigger | "press" | "hover" | "press" | Press scratches while the pointer is held down. Hover scratches as the mouse moves. Touch always scratches on drag. |
revealStyle | "crumble" | "fade" | "crumble" | How the last of the foil clears. Crumble tears it into flakes that peel away from where you stopped and flutter down. Fade dissolves it. |
intro | boolean | true | The card settles into place and the foil catches the light the first time it scrolls into view. |
resetDelay | number | 0 | Milliseconds before the foil comes back after a reveal. 0 keeps the card revealed. |
theme | "auto" | "light" | "dark" | "auto" | Auto matches the card to the background behind it. |
foilColor | string | from finish | Tints the foil with your own colour instead of the finish. |
cardColor | string | from theme | Colour of the card under the foil. |
inkColor | string | from theme | Colour of the revealed text. |
onScratch | (progress: number) => void | — | Called as the foil is scratched, with the share cleared from 0 to 1. |
onReveal | () => void | — | Called once the card is revealed. |
ref | { reveal, reset } | — | Reveals the card or brings the foil back from your own code. |
className | string | — | Classes for the root element. |
style | CSSProperties | — | Inline styles for the root element. |
childrenReactNodeWhat sits under the foil. Replaces the built-in title and code.
—titlestringLarge line revealed under the foil.
"40% off"codestringCode shown under the title. Click it after the reveal to copy it.
"SPRING40"labelstringHint printed on the foil. An empty string hides it.
"Scratch to reveal"widthnumberCard width in pixels. The card shrinks to fit narrower spaces.
360heightnumberCard height in pixels. The ratio is kept when the card shrinks.
224radiusnumberCorner radius of the card.
18finish"silver" | "gold" | "holographic" | "graphite"Look of the foil. The light bands slide with the pointer.
"silver"brushSizenumberRadius of the scratch in pixels.
22thresholdnumberShare of the foil scratched away before the rest clears by itself.
0.6flakesbooleanSmall foil flakes tumble off as you scratch.
trueshimmerbooleanTilts the light across the foil now and then until someone scratches.
truetrigger"press" | "hover"Press scratches while the pointer is held down. Hover scratches as the mouse moves. Touch always scratches on drag.
"press"revealStyle"crumble" | "fade"How the last of the foil clears. Crumble tears it into flakes that peel away from where you stopped and flutter down. Fade dissolves it.
"crumble"introbooleanThe card settles into place and the foil catches the light the first time it scrolls into view.
trueresetDelaynumberMilliseconds before the foil comes back after a reveal. 0 keeps the card revealed.
0theme"auto" | "light" | "dark"Auto matches the card to the background behind it.
"auto"foilColorstringTints the foil with your own colour instead of the finish.
from finishcardColorstringColour of the card under the foil.
from themeinkColorstringColour of the revealed text.
from themeonScratch(progress: number) => voidCalled as the foil is scratched, with the share cleared from 0 to 1.
—onReveal() => voidCalled once the card is revealed.
—ref{ reveal, reset }Reveals the card or brings the foil back from your own code.
—classNamestringClasses for the root element.
—styleCSSPropertiesInline styles for the root element.
—