Components / Backgrounds
Interactive Dot Grid
A canvas grid of dots that glow and push away from the cursor.
Move your cursor
The dots light up and push away.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
None. This component only needs React and Tailwind.
- 2
Add the component
Copy the code from the Code tab above into
components/ui/dot-grid.tsx. - 3
Use it
example.tsximport { DotGrid } from "@/components/ui/dot-grid"; export default function DotGridDemo() { return ( <DotGrid className="h-72 w-full rounded-2xl border border-zinc-200 dark:border-white/10 bg-white dark:bg-zinc-950"> <div className="pointer-events-none flex h-full flex-col items-center justify-center text-center"> <h3 className="text-2xl font-semibold text-zinc-900 dark:text-white">Move your cursor</h3> <p className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">The dots light up and push away.</p> </div> </DotGrid> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| gap | number | 22 | Space between dots (px). |
| dotSize | number | 1.4 | Dot radius (px). |
| color | string | "rgba(255,255,255,0.14)" | Resting dot color. |
| activeColor | string | "#fb923c" | Color near the cursor. |
| radius | number | 130 | Reach of the cursor effect (px). |