Lab/01
Interactive Dot Grid
A field of dots that move aside and turn vermilion as the cursor passes. Drawn every frame with a soft falloff radius.
- Canvas
- Interaction
Move across the field
lab/dot-gridInstallation
Add Dot Grid to your project with the shadcn CLI. The files land in components/lab, ready to edit.
$ pnpm dlx shadcn@latest add @soultel/lab-dot-gridOr by URL: https://asafefe.dev/r/lab-dot-grid.json
Brings along
- utils
- @soultel/lab-canvas
Usage
import { DotGrid } from "@/components/lab/dot-grid"
export function Hero() {
return (
<section className="relative h-96">
<DotGrid className="absolute inset-0" />
<h1 className="relative">Hello</h1>
</section>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| gap | number | 24 | Distance between dots in px. |
| radius | number | 130 | Cursor influence radius in px. |
| push | number | 14 | How far dots move aside at the cursor, in px. |
| dotSize | number | 1.1 | Idle dot radius in px. |
| color | string | "var(--foreground)" | Idle dot color. Any CSS color. |
| activeColor | string | "var(--primary)" | Color near the cursor. |
| opacity | number | 0.16 | Idle dot opacity. |
