Kinetic UI
Back to Introduction
Mouse Interactions

Scratch to Reveal

A canvas component where the user scratches with their cursor to reveal hidden content.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add scratch-to-reveal

An interactive canvas component that uses globalCompositeOperation = "destination-out" to allow the user to "scratch" away a top layer and reveal hidden content underneath. Great for easter eggs or gamified interactions.

Live Preview

Scratch to Reveal

You Won!

Enjoy your exclusive lifetime access to the creative library.

Installation

npx kinetic-ui-cli@latest add scratch-to-reveal

Usage Guide

1. Import the Component

Import the component into your React or Next.js page:

import { ScratchToReveal } from "@/components/creative/scratch-to-reveal";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { ScratchToReveal } from "@/components/creative/scratch-to-reveal";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <ScratchToReveal
        width{10}
        height{10}
        brushSize{10}
      >
        <div>Content goes here</div>
      </ScratchToReveal>
    </div>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.