Skip to content
WANCRAFT

E.20Backgrounds & Effects

Cursor Glow

A soft light that follows the pointer inside a container and catches its border.

ReactCSSTailwindbasic

Overview

Cursor Glow wraps any content in a surface lit by a soft radial light that trails the mouse. The position is eased in a requestAnimationFrame loop and written straight to CSS variables (--glow-x, --glow-y), so React never re-renders on pointer move and children can reuse the variables. The glow fades in and out on enter and leave, optionally lights the container's 1px border, and stays off for touch input.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/cursor-glow.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/cursor-glow.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/cursor-glow.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
1 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { CursorGlow } from "@/components/ui/cursor-glow";

export function CursorGlowExample() {
  return (
    <CursorGlow
      className="rounded-2xl border border-zinc-900/10 bg-white p-8 dark:border-white/10 dark:bg-zinc-950"
    >
      <h3 className="text-lg font-medium">Lit by your cursor</h3>
      <p className="mt-2 text-sm text-zinc-500">Move the mouse across this panel.</p>
    </CursorGlow>
  );
}

03Props

PropTypeDefaultDescription
radiusnumber220Glow radius in px; also sizes the border light.
blurnumber40Additional blur in px.
colorstring"#FF7448"Glow colour (any CSS colour).
intensitynumber0.45Peak glow opacity (0–1).
easingnumber0.15Per-frame smoothing (0.02–1), normalised to 60 fps.
borderbooleantrueLights the container's 1px edge near the pointer (inherits border radius).
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root; ref is forwarded. Pointer handlers you pass are still called.

04Features

  • 01rAF-eased position written to CSS variables — no re-render per move
  • 02Frame-rate independent smoothing; loop stops as soon as the glow settles
  • 03Fades in/out on enter/leave, clipped to the container
  • 04Optional 1px border light using a masked radial gradient
  • 05Exposes --glow-x / --glow-y to children for custom effects
motion · continuousmotion · tweeninput · pointerinput · hover

05Accessibility

  • Glow layers are aria-hidden and ignore pointer events — content stays fully interactive.
  • Touch and pen input never show the glow.
  • prefers-reduced-motion snaps the glow to the pointer and disables fade transitions.