Components

Dot Spotlight

A dot grid background with a subtle cursor spotlight for React: a small light follows the mouse and brightens only the dots beneath it, with no color wash. Built with Motion values and a CSS mask, so it never re-renders, and it rests dimly in the center on touch screens.

  • Background
  • Dot grid
  • Cursor spotlight
  • Motion values
  • Touch fallback

Find slow requests faster

Traces, logs and metrics for every endpoint, in one view.

Installation

$ npx shadcn@latest add https://duskui.com/r/dot-spotlight.json

The pattern fills its nearest positioned parent, so give the parent relative and overflow-hidden, and put your content after it with relative so it sits on top. The cursor is tracked on the window, so content on top stays fully interactive.

Usage

hero.tsx
import { DotSpotlight } from "@/components/dusk/backgrounds/dot-spotlight"

export function Hero() {
  return (
    <section className="relative overflow-hidden">
      <DotSpotlight />
      <div className="relative">{/* your content */}</div>
    </section>
  )
}

Examples

Grid & color

gap and dotSize shape the grid, radius sizes the light, and color sets the lit dots. Keep it low-alpha so the light stays subtle.

gap={14} dotSize={1}
gap={28} dotSize={1.5}

Behind a feature grid

Turn off fade to run the pattern edge to edge behind cards; the light still follows the cursor through them.

Fast

p99 under 40 ms.

Secure

Encrypted end to end.

Observable

Traces on every call.

API Reference

Any other div prop is passed to the root. The spotlight position is spring-smoothed and stored in percent of the container, so the server renders the centered resting state.

PropTypeDefaultDescription
colorstring"rgb(255 255 255 / 0.4)"Color of the lit dots.
dotColorstring"rgb(255 255 255 / 0.1)"Color of the resting dots.
gapnumber20Distance between dots in px.
dotSizenumber1.25Dot radius in px.
radiusnumber160Radius of the spotlight in px.
fadebooleantrueFade the pattern out toward the edges.
classNamestring—Merged onto the absolutely positioned root.

Accessibility

  • The pattern is decorative: it is aria-hidden and pointer-events-none, so it never reaches screen readers or blocks clicks.
  • On touch screens and with prefers-reduced-motion the light rests, dim and still, in the center.
  • Pointer tracking is skipped while the pattern is off-screen or the tab is hidden.
  • The effect is pure decoration; never rely on it to reveal content.