Grid Pattern
FreeAn SVG line grid with optional highlighted cells and an edge fade.
Installation
pnpm dlx shadcn@latest add @viewport/grid-pattern
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { GridPattern } from "@/components/viewport/grid-pattern";
export default function GridPatternDemo() {
return (
<div className="relative grid h-80 w-full place-items-center overflow-hidden rounded-2xl border border-border bg-background">
<GridPattern
squares={[[4, 2], [7, 4], [10, 1], [12, 5], [2, 5], [15, 3]]}
/>
<h2 className="relative text-3xl font-semibold tracking-tight">Structure, quietly</h2>
</div>
);
}Props
| Prop | Type | Default |
|---|---|---|
| size | numberCell size in pixels. | 40 |
| squares | [number, number][]Cells to fill, as [column, row] pairs. | [] |
| fade | booleanFade the pattern out toward the edges. | true |
Accessibility
- Decorative and aria-hidden.
- Static, so it is safe for every motion preference.
- Server component with no client JavaScript.