Interactive Grid
NewBackground grid whose squares light up under the pointer and fade behind it. Canvas-drawn, paused off screen.
Move your pointer
Squares light up and fade behind you. Set the colour with a text class.
Installation
$ pnpm dlx shadcn@latest add @synccn/interactive-gridFirst time in this project? Connect synccn with one command.
Usage
import { InteractiveGrid } from "@/components/ui/interactive-grid";<InteractiveGrid className="h-72 text-primary">…</InteractiveGrid>API reference
Generated from the component's TypeScript types, so it always matches the code.
InteractiveGrid
Background grid whose squares light up under the pointer and fade out behind it. Drawn on a canvas, paused when off screen, and static for people who prefer reduced motion.
- cellSize
numberDefault
32Size of each square, in pixels.
- radius
numberDefault
1How many cells around the pointer light up.
- fade
numberDefault
900How long a lit cell takes to fade, in milliseconds.
- ambient
booleanDefault
trueLights random cells now and then, so the grid looks alive on touch screens too.
- className
stringExtra classes for the root element. The grid uses the text colour, so set it with a text-* class.
- children
React.ReactNodeContent shown over the grid.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
Accessibility
- The canvas is hidden from assistive tech. With reduced motion the grid is drawn once and doesn't react.
From the source
Read from this component's code when the site builds, so it can't drift.
- Respects the reduced motion setting