Scratch To Reveal

The ScratchToReveal component creates an interactive scratch-off effect with customizable dimensions and animations, revealing hidden content beneath.

Install using CLI

npm
pnpm
bun
yarn
npx shadcn-vue@latest add "https://inspira-ui.com/r/scratch-to-reveal.json"

Install Manually

Copy and paste the following code

ScratchToReveal.vue

API

Prop NameTypeDefaultDescription
classstring""The class name to apply to the component.
widthnumber""Width of the scratch container.
heightnumber""Height of the scratch container.
minScratchPercentagenumber50Minimum percentage of scratched area to be considered as completed (Value between 0 and 100).
gradientColors[string,string,string]-Gradient colors for the scratch effect.
Event NamePayloadDescription
complete-Callback function called when scratch is completed
Slot NameDefault ContentDescription
default-The text below the scratch-off ticket.

Component Code

You can copy and paste the following code to create this component:

ScratchToReveal.vue

Credits