Dot Grid Spotlight

Interactive dot grid with a cursor-tracking spotlight effect.

runed

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/dot-grid-spotlight.json

Usage

preview.svelte

Features

  • Interactive dot grid with a cursor-tracking spotlight effect
  • Customizable dot color, active color, spacing, and radius via props
  • Adjustable interaction radius and alpha range for the spotlight glow

Examples

Custom colors

Props

DotGridSpotlight

Canvas dot grid with a pointer-driven spotlight.

NameTypeDefaultDescription
dotColorstring'rgba(255, 255, 255, 0.05)'Color used for inactive dots.
activeDotColorstring'rgba(255, 255, 255, 0.1)'Color used for dots illuminated by the pointer.
spacingnumber10Distance between dots in pixels.
baseRadiusnumber1Radius of inactive dots in pixels.
activeRadiusnumber2Radius of a dot at the center of the spotlight.
interactionRadiusnumber128Radius of the pointer spotlight in pixels.
activeMaxAlphanumber1Opacity applied at the center of the spotlight.
activeMinAlphanumber0.5Opacity applied at the edge of the spotlight.
refHTMLCanvasElement | nullnullBindable reference to the canvas element.
classstringundefinedAdditional classes applied to the canvas.