React Dot Pattern Background

Interactive dot matrix with mouse-reactive glow effects and ambient wave animation, rendered on canvas for smooth performance.

Usage

Default (Auto Dark/Light)

import { DotPattern } from "@/components/BackgroundPatterns/dot-pattern"

export default function Page() {
  return <DotPattern />
}

Props

PropTypeDefaultDescription
dotSizenumber2Diameter of each dot in pixels
gapnumber24Spacing between dots in pixels
darkBaseColorstring (hex)"#404040"Base dot color in dark theme
lightBaseColorstring (hex)"#c0c0c0"Base dot color in light theme
darkGlowColorstring (hex)"#22d3ee"Mouse hover glow color in dark theme
lightGlowColorstring (hex)"#6366f1"Mouse hover glow color in light theme
darkBgColorstring (hex)"#0a0a0a"Canvas background color in dark theme
lightBgColorstring (hex)"#ffffff"Canvas background color in light theme
proximitynumber120Mouse proximity radius in pixels for glow trigger
glowIntensitynumber1Multiplier for glow brightness strength
waveSpeednumber0.5Ambient wave animation speed. Set to 0 to disable
childrenReactNodeContent rendered above the dot pattern canvas
classNamestringAdditional CSS classes for the container element

Notes

  • Canvas rendering — Uses HTML5 Canvas with requestAnimationFrame for smooth 60fps animation with zero DOM overhead.
  • Theme detection — Automatically reads resolvedTheme from next-themes. Grid rebuilds on theme switch.
  • Retina support — Scales canvas by devicePixelRatio for sharp rendering on HiDPI screens.
  • Responsive — Uses ResizeObserver to rebuild the dot grid whenever the container is resized.
  • Wave animation — Set waveSpeed={0} to disable ambient animation and keep dots static.
  • Glow effect — Uses smoothstep easing for natural, non-linear proximity transitions.
  • Performance — Mouse position is tracked via a ref (not state) to avoid unnecessary re-renders.
Lokalhost.io

At Lokalhost.io, we provide developers, startups, and creative teams with high-quality templates, components, UI kits, and design resources.

Created by@hilal

Stay in the loop

No spam. Only meaningful updates, releases & dev notes.

$

Find me here.

Mobile Appssoon

© 2026 Lokalhost.io — All rights reserved.

React Dot Pattern Background — Lokalhost.io