Components / Backgrounds
Grid Pattern
A faded grid background whose squares softly light up at random.
Built on a grid
Squares softly light up at random.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/grid-pattern.tsx. - 3
Use it
example.tsximport { GridPattern } from "@/components/ui/grid-pattern"; export default function GridPatternDemo() { return ( <GridPattern className="flex h-72 w-full items-center justify-center rounded-2xl border border-zinc-200 bg-white dark:border-white/10 dark:bg-zinc-950"> <div className="text-center"> <h3 className="text-2xl font-semibold text-zinc-900 dark:text-white">Built on a grid</h3> <p className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">Squares softly light up at random.</p> </div> </GridPattern> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| cellSize | number | 40 | Grid cell size (px). |
| count | number | 14 | Squares lit at once. |
| interval | number | 700 | Milliseconds between new squares. |
| children | ReactNode | — | Content on top. |