npm i @dellamora/scratch-to-reveal-svelte
<ScratchToReveal
width={250}
height={250}
minScratchPercentage={70}
gradientColors={["#A97CF8", "#F38CB8", "#FDCC92"]}
onComplete={() => console.log('done!')}
>
<p style="font-size: 6rem;">Hiii</p>
</ScratchToReveal>
width
/ height
→ Canvas sizeminScratchPercentage
→ When to trigger complete eventgradientColors
→ Overlay colors imageUrl
→ Optional image to use instead of gradientonComplete
→ Completion callbackclassName
→ Custom CSS classeson:complete
→ Fired when reveal threshold is hiton:scratchProgress
→ Live percentage updates.reveal()
→ Reveal all content programmatically.reset()
→ Reset to initial scratch stateMIT. Build fun stuff.
PRs welcome!