Skip to content
GitHub

Flickering Grid

A flickering grid background made with SVGs

import { FlickeringGrid } from "@/components/backgrounds/pxl/flickering-grid";
export default function FlickeringGridDemo() {
return (
<FlickeringGrid
/>
);
}
pnpm dlx shadcn@latest add pxl-ui/registry/backgrounds/flickering-grid
import { FlickeringGrid } from "@/components/backgrounds/pxl/flickering-grid"
<FlickeringGrid />

Use the size prop to change the size of the squares.

"use client";
import { FlickeringGrid } from "@/components/backgrounds/pxl/flickering-grid";
export default function FlickeringGridSizes() {
return (
<FlickeringGrid
size="lg" />
);
}

Use the variant prop to change the colors of the grid.

"use client";
import { FlickeringGrid } from "@/components/backgrounds/pxl/flickering-grid";
export default function FlickeringGridVariants() {
return (
<div className="flex flex-wrap size-full items-center justify-center gap-2">
<div className="relative w-max h-32 aspect-video pixel-rounded pixel-size-lg">
<FlickeringGrid
variant="muted"
/>
</div>
<div className="relative w-max h-32 aspect-video pixel-rounded pixel-size-lg">
<FlickeringGrid
variant="primary"
/>
</div>
<div className="relative w-max h-32 aspect-video pixel-rounded pixel-size-lg">
<FlickeringGrid
variant="info"
/>
</div>
<div className="relative w-max h-32 aspect-video pixel-rounded pixel-size-lg">
<FlickeringGrid
variant="success"
/>
</div>
<div className="relative w-max h-32 aspect-video pixel-rounded pixel-size-lg">
<FlickeringGrid
variant="warning"
/>
</div>
<div className="relative w-max h-32 aspect-video pixel-rounded pixel-size-lg">
<FlickeringGrid
variant="danger"
/>
</div>
</div>
);
}
import { FlickeringGrid } from "@/components/backgrounds/pxl/flickering-grid";
export default function FlickeringGridRoundedDemo() {
return (
<FlickeringGrid
className="mask-[radial-gradient(200px_circle_at_center,white,transparent)]"
/>
);
}
Prop Type Default Description
size "default" | "4xs" | "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" "default" Size of the squares
variant "default" | "primary" | "secondary" | "muted" | "success" | "warning" | "danger" "default" Colors of the grids
gridGap number 6 Gap between squares in the grid
flickerChance number 0.3 Probability of a square flickering
className string - Additional CSS classes for the canvas
maxOpacity number 0.2 Maximum opacity of the squares