Grid Pattern
Fill a background with a grid of lines or dots, with optional cells that glow on and off.
Overview
Grid Pattern draws an SVG grid of lines or dots that fills its parent. Set numSquares to make that many random cells glow on and fade out in turn, or pass squares for cells that stay filled. A fade mask softens the grid toward its edges so it sits behind content without a hard frame. The pattern uses currentColor, so a text color class such as text-foreground/15 sets its tint in both themes.
Installation
Usage
import { GridPattern } from "@/components/animated/grid-pattern"
<div className="relative overflow-hidden rounded-xl border">
<GridPattern numSquares={18} fade="radial" />
<div className="relative p-8">Content</div>
</div>Use variant="dots" with a smaller width and height for a quieter dot field, and strokeDasharray for dashed lines.
Accessibility
The grid is decorative and hidden from assistive technology. Glowing cells are chosen on the client after mount, so server and client markup match. When reduced motion is requested, cells do not animate and only the static grid and any fixed squares are drawn.