Dark screen with a moving spotlight beam revealing hidden glowing text that says DIGITAL

SVG Flashlight Reveal Effect

This is an SVG Flashlight Reveal Effect. It animates a volumetric cone of light across a dark canvas, using SVG masking to dynamically reveal and illuminate hidden text. Its function is to create a cinematic, narrative-driven focal point, turning standard typography into an exploratory visual experience.

Technologies:
HTML CSS JavaScript
Difficulty: Intermediate
Browser Support (as of May 2026):
Chrome Chrome 51+ Edge Edge 79+ Firefox Firefox 54+ Safari Safari 10+
Features:
SVG Masking Animated Gradients Stroke Animation
Code by: isladjan isladjan
License: MIT

See the Pen SVG Flashlight Reveal Effect.

Spotlight Cursor on Responsive Image

Spotlight Cursor on Responsive Image

A unique, zero-dependency “flashlight” UI effect achieved by dynamically positioning a large, transparent-to-radial-gradient element via Vanilla JavaScript mousemove, and using the powerful CSS mix-blend-mode: exclusion to create the inverted color effect over the background image.

Animated Flashlight Pattern Background

A unique Pure CSS implementation of a spotlight animation achieved without any JavaScript. The effect relies on controlling the clip-path position via CSS animation, alongside color change and element blinking managed by multiple stops within the detailed @keyframes.

Frequently Asked Questions

Why is passing cursor coordinates to CSS custom properties more performant than animating DOM positions directly?

Using JavaScript strictly as a minimal bridge to update --x and --y variables isolates the imperative logic from the layout pipeline. The browser’s compositor thread resolves the actual visual interpolation of the radial gradient mask, preventing expensive main-thread style recalculations and protecting critical INP metrics.

How do you maintain accessibility (A11y) for a hidden layout that relies on a flashlight to reveal content?

Flashlight effects must remain purely decorative; content should never be truly inaccessible to search engines or keyboard users. Ensure the covered elements remain natively visible in the DOM, keep aria-hidden="false", and implement a fallback where focused elements automatically reveal themselves using :focus-within or :has() focus selectors.

When should a developer choose radial-gradient over clip-path for a spotlight or flashlight effect?

A radial-gradient is ideal when you require soft, feathered light edges or semi-transparent visual falloffs, which are highly efficient to render. Conversely, use clip-path with the circle() function if you need a razor-sharp spotlight mask that clips interactive mouse events so only the illuminated area accepts clicks.

Does registering spotlight coordinate variables with @property provide rendering advantages?

Yes, registering --x and --y via the @property API declares their exact types, allowing the browser to optimize paint steps. It also enables native CSS transitions directly on those custom properties, facilitating smooth spotlight centering or easing effects without any extra script overhead.

What is the optimal fallback strategy for flashlight layouts on mobile touch devices?

On touch screens, the concept of hover tracking does not exist, and dragging a touch-point can interfere with natural scrolling. Utilize @media (hover: hover) to isolate the pointer-tracking logic for desktop users, and gracefully degrade to an automatic pulse animation or a static fully-illuminated state for mobile viewports.