Components

Flickering Grid

A flickering grid background for React: a canvas of tiny squares that twinkle on and off at random, like a server rack or a field of pixels. Seeded so every mount starts from the same pattern, it can also be masked to a word so the squares spell out text.

  • Background
  • Canvas
  • Text mask
  • Seeded pattern
  • High-DPI
  • Pauses off-screen
  • Reduced-motion safe

All systems operational

99.98% uptime across 24 regions over the last 90 days.

Installation

$ npx shadcn@latest add https://duskui.com/r/flickering-grid.json

The grid fills its nearest positioned parent, so give the parent relative and overflow-hidden. Fade the edges with a Tailwind mask-image class on the grid itself.

Usage

status.tsx
import { FlickeringGrid } from "@/components/dusk/flickering-grid/flickering-grid"

export function Status() {
  return (
    <section className="relative overflow-hidden">
      <FlickeringGrid squareSize={4} gap={6} maxOpacity={0.3} />
      <div className="relative">{/* your content */}</div>
    </section>
  )
}

Examples

Text mask

Pass text and squares are only drawn inside the letters. The word is scaled to fit unless you set fontSize; fontWeight and fontFamily shape it. The canvas is hidden from assistive tech, so repeat the word in an sr-only element.

Dusk

Squares & color

squareSize and gap set the pitch, maxOpacity the brightest square and flickerChance how often each square changes per second. seed picks a different, stable pattern.

squareSize={2} gap={4}
squareSize={8} gap={3}

API Reference

Any other div prop is passed to the root. Squares are drawn to a single <canvas> sized to the device pixel ratio and redrawn on resize.

PropTypeDefaultDescription
squareSizenumber4Side of each square in px.
gapnumber6Space between squares in px.
flickerChancenumber0.15Chance per square per second of changing brightness; 0 holds it still.
colorstring"rgb(255 255 255)"Square color. Any CSS color, including theme variables.
maxOpacitynumber0.15Opacity of the brightest square, 0–1.
seednumber1Seed for a different, but stable, pattern.
textstring—Only draw squares inside this text.
fontSizenumberfitMask text size in px; fits the container when omitted.
fontWeightnumber | string700Mask text weight.
fontFamilystringinheritedMask text font family.
classNamestring—Merged onto the absolutely positioned root.

Accessibility

  • The grid is decorative: it is aria-hidden and pointer-events-none. With text, render the same words in real (or sr-only) text.
  • With prefers-reduced-motion one still frame of the pattern is drawn and nothing flickers.
  • Drawing stops while the grid is off-screen or the tab is hidden.
  • Flicker is gentle and random rather than a strobe; keep flickerChance modest and maxOpacity low behind body copy.