127+ Primitives

Flickering Grid

Backgrounds

High-performance HTML5 canvas flickering retro grid background with device-pixel-ratio scaling, probabilistic opacity stepping, and automatic offscreen pausing via IntersectionObserver.

CanvasPerformanceIntersectionObserverDPR Aware
/r/flickering-grid.json
Flickering Grid Canvas

Device-pixel-ratio scaled • Battery-aware auto pause

Installation

Install directly into your project using the shadcn CLI or copy the source code manually.

Requires:clsxtailwind-merge
$npx shadcn@latest add "https://boseui.site/r/flickering-grid.json"

Props

TypeScript props supported by <FlickeringGrid />.

8 props
PropTypeDefaultDescription
squareSizenumber4Dimension of each square cell in CSS pixels.
gridGapnumber6Spacing between adjacent cells in CSS pixels.
flickerChancenumber0.3Probability of a cell recalculating its opacity per second [0..1].
colorstring"rgb(0, 0, 0)"CSS color string for the rendered grid squares.
maxOpacitynumber0.3Maximum opacity ceiling for the grid squares.
widthnumberundefinedOptional explicit fixed width override in pixels.
heightnumberundefinedOptional explicit fixed height override in pixels.
classNamestringundefinedAdditional Tailwind CSS classes merged into the container.

Key Features

  • GPU-accelerated HTML5 2D canvas rendering with subpixel device-pixel-ratio sharpness.
  • Dynamic delta-time calibrated probabilistic flickering so frame rate fluctuations do not affect animation speed.
  • Battery-friendly IntersectionObserver automatically halts requestAnimationFrame loops when scrolled out of view.
  • Fast SSR-safe color parser with support for hex, rgb, and CSS color names.

Keyboard & Accessibility

  • Decorative canvas marked with pointer-events-none so it does not intercept user clicks.
  • Gracefully respects viewport resizing without layout shifts.