A background grid pattern made with SVGs.
Installation
Section titled “Installation”pnpm dlx shadcn@latest add pxl-ui/registry/backgrounds/grid-pattern
Copy and paste the following code into your project.
Update the import paths to match your project setup.
import { GridPattern } from "@/components/backgrounds/pxl/grid-pattern"<GridPattern />Linear Gradient
Section titled “Linear Gradient”Dashed Stroke
Section titled “Dashed Stroke”Variants
Section titled “Variants”Use the variant prop to change the colors of the grid.
API Reference
Section titled “API Reference”GridPattern
Section titled “GridPattern”| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
- |
Additional classes to be added to the pattern |
variant |
"default" | "primary" | "secondary" | "muted" | "success" | "warning" | "danger" |
"default" |
Colors of the grids |
width |
number |
40 |
Width of the pattern |
height |
number |
40 |
Height of the pattern |
x |
number |
-1 |
X offset of the pattern |
y |
number |
-1 |
Y offset of the pattern |
strokeDasharray |
number |
0 |
Stroke dash array of the pattern |
numSquares |
number |
200 |
Number of squares in the pattern |
maxOpacity |
number |
0.5 |
Maximum opacity of the pattern |
duration |
number |
1 |
Duration of the animation |
repeatDelay |
number |
0.5 |
Repeat delay of the animation |