Cursor Flashlight
Interactive & Advanced · Animated · pure CSS
The word sits dim until your cursor sweeps over it, lighting a bright glowing disc that tracks the pointer. A flashlight reveal driven by a tiny script.
How it works
Cursor Flashlight is an animated interactive & advanced text effect rendered entirely in CSS. A data-text attribute mirrors the word into ::before/::after layers, so copy that attribute together with the CSS. It reacts to the pointer through CSS custom properties updated by a tiny inline script.
Controls
Cursor Flashlight exposes 2 dedicated controls — Hue and Beam Size — on top of the shared type controls (font, weight, letter-spacing and case). Open it in the generator to tune every value live, then copy the updated CSS.
CSS
/* Cursor Flashlight — generated with TEXT-FX
* HTML: the element needs a data-text attribute equal to its text; needs the small pointer-move JS snippet.
* Font: 'Anton', sans-serif (load from Google Fonts).
*/
.text-effect {
font-family: 'Anton', sans-serif;
font-weight: 400;
letter-spacing: 8px;
text-transform: none;
}
.text-effect {
--mx: 50%;
--my: 50%;
position: relative;
color: hsl(284 20% 40%);
}
.text-effect::after {
content: attr(data-text);
position: absolute;
inset: 0;
color: hsl(284 95% 64%);
text-shadow: 0 0 8px hsl(284 100% 60%), 0 0 22px hsl(284 100% 60%);
-webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, #000 31%, transparent 51%);
mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, #000 31%, transparent 51%);
pointer-events: none;
}
HTML
This effect needs the markup below (per-letter spans, SVG defs, or a data-text attribute).
<style>
.text-effect {
font-family: 'Anton', sans-serif;
font-weight: 400;
letter-spacing: 8px;
text-transform: none;
}
.text-effect {
--mx: 50%;
--my: 50%;
position: relative;
color: hsl(284 20% 40%);
}
.text-effect::after {
content: attr(data-text);
position: absolute;
inset: 0;
color: hsl(284 95% 64%);
text-shadow: 0 0 8px hsl(284 100% 60%), 0 0 22px hsl(284 100% 60%);
-webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, #000 31%, transparent 51%);
mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, #000 31%, transparent 51%);
pointer-events: none;
}
</style>
<div data-text="Your text" class="text-effect">Your text</div>
<script>
const fx = document.querySelector('.text-effect');
if (fx) {
fx.addEventListener('pointermove', (e) => {
const r = fx.getBoundingClientRect();
if (!r.width || !r.height) return;
fx.style.setProperty('--mx', ((e.clientX - r.left) / r.width) * 100 + '%');
fx.style.setProperty('--my', ((e.clientY - r.top) / r.height) * 100 + '%');
});
fx.addEventListener('pointerleave', () => {
fx.style.removeProperty('--mx');
fx.style.removeProperty('--my');
});
}
</script>
- Category
- Interactive & Advanced
- Type
- Animated
- Browser support
- Follows the cursor via a pointer-tracked radial mask — static preview shows the centred disc.
- Capabilities
- dataText, pointer