Flickering Grid

A customizable Flickering Grid background component for Svelte 5, rendered efficiently with Canvas and styled using Tailwind CSS.

Installation

pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/flickering-grid.json

Usage

<script lang="ts">	import { FlickeringGrid } from "#lib/components/magic/flickering-grid/index.js";</script>
<div class="relative h-64 overflow-hidden">	<FlickeringGrid class="absolute inset-0 size-full" /></div>

Examples

Basic Usage

A simple flickering grid background.

Header Backdrop

A sparse emerald grid faded away from the heading to keep the text readable.

Developer reference

API documentation

Inset Panel

A denser amber grid confined to a panel header, leaving the content area still.

Design resources

Tokens, type scales, and component guidelines.

Props

Flickering Grid

A component for creating a flickering grid background.

NameTypeDefaultDescription
classClassValue""Additional CSS classes to apply
squareSizenumber4The size of each square in the grid
gridGapnumber6The gap between squares in the grid
flickerChancenumber0.3The chance of each square flickering
colorstringrgb(0, 0, 0)The color of the squares
widthnumberThe width of the grid
heightnumberThe height of the grid
maxOpacitynumber0.3The maximum opacity of the squares