• Logo

    Elementra UI

    v0.1.7 - Documentation
  1. Docs
  2. Components/Scratch-To-Reveal/

Scratch To Reveal

An interactive scratch card component that reveals content when scratched.

1Installation

npm i elementra-ui

2Add Components Using CLI

npx elementra-ui add

Select components using the up/down arrow keys. Press spacebar to select multiple components, then press enter to add them to your src folder.

🎉

3:Radial gradient prize reveal with bounce animation

Import and use the ScratchToReveal component in your project.

🎁

You Won!

$50 Gift Card

4:Circular scratch card with fade animation

Import and use the ScratchToReveal component in your project.

🏆

5:Discount code reveal with spin animation

Import and use the ScratchToReveal component in your project.

Your special code:

FREE50OFF

Valid until May 31, 2025

6:Props Reference

PropTypeDefaultDescription
widthnumberrequiredWidth of the scratch card in pixels
heightnumberrequiredHeight of the scratch card in pixels
minScratchPercentagenumber100Percentage of the card that needs to be scratched to trigger completion
onCompletefunctionundefinedCallback function triggered when scratch is completed
variantstring'gradient'Style of the scratch overlay: 'gradient', 'radial', 'solid', 'pattern'
gradientColorsarray['#A97CF8', '#F38CB8', '#FDCC92']Array of colors for gradient overlays
scratchRadiusnumber30Size of the scratch area when scratching
backgroundColorstring'#f0f0f0'Background color of the component
revealAnimationstring'pop'Animation on reveal: 'pop', 'fade', 'spin', 'bounce'
cursorSizenumber32Size of the scratch cursor in pixels
borderRadiusstring'24px'Border radius of the scratch card
showOverlayOnlybooleantrueWhen true, hides content until scratched