Kinetic UI
Back to Introduction
Media

SVG Flashlight Mask

A dual-layer component that uses a dynamic SVG/CSS radial gradient mask to reveal hidden content underneath your cursor.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add svg-flashlight-mask
SVG Flashlight Mask

HOVER TO REVEAL

The magic is hidden in the dark.

SVG FLASHLIGHT

CSS Masking powered by Framer Motion.

Installation

npx kinetic-ui-cli@latest add svg-flashlight-mask

How It Works

The SvgFlashlightMask allows you to stack two completely different React layouts on top of one another. The top layout (the revealChildren) is completely clipped out of existence using the maskImage CSS property. By feeding the X and Y coordinates of your cursor from framer-motion into a radial-gradient mask via CSS custom variables (--x and --y), it creates a "hole" in the clipping mask, causing the top layer to peek through precisely where your mouse is pointing, acting like a flashlight in the dark.

Usage Guide

1. Import the Component

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

import { SvgFlashlightMask } from "@/components/creative/svg-flashlight-mask";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { SvgFlashlightMask } from "@/components/creative/svg-flashlight-mask";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <SvgFlashlightMask
        revealChildren{/* value */}
        maskSize{10}
      >
        <div>Content goes here</div>
      </SvgFlashlightMask>
    </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.