Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Backgrounds

  • DotPattern
  • GridPattern
  • StripedPattern
  • Spotlight
  • FadeMask
  • RetroGrid
  • Ripple
  • Meteors
  • Aurora
  • Particles
  • FlickeringGrid
  • WavyBackground
  • Silk
  • Iridescence
  • Threads
  • Orb
  • LiquidChrome
  • Balatro
  • Ballpit
  • Beams
  • ColorBends
  • DarkVeil
  • Dither
  • DotField
  • EvilEye
  • FaultyTerminal
  • Ferrofluid
  • FloatingLines
  • Galaxy
  • GradientBlinds
  • Grainient
  • GridDistortion
  • GridMotion
  • GridScan
  • Hyperspeed
  • LetterGlitch
  • Lightfall
  • Lightning
  • LightPillar
  • LightRays
  • LineWaves
  • LiquidEther
  • PixelBlast
  • PixelSnow
  • Plasma
  • PlasmaWave
  • Prism
  • PrismaticBurst
  • Radar
  • RippleGrid
  • ShapeGrid
  • SideRays
  • SoftAurora

Overlay Effects

  • BorderBeam
  • ShineBorder
  • GlareHover
  • Lens
  • AnimatedBeam
  • OrbitingCircles
  • ProgressiveBlur
  • CardSpotlight
  • Reveal
  • Antigravity
  • BlobCursor
  • ClickSpark
  • Crosshair
  • ElectricBorder
  • GhostCursor
  • GradualBlur
  • ImageTrail
  • LaserFlow
  • MagicRings
  • Magnet
  • MagnetLines
  • MetaBalls
  • MetallicPaint
  • OrbitImages
  • PixelTrail
  • PixelTransition
  • Ribbons
  • ShapeBlur
  • SplashCursor
  • StarBorder
  • StickerPeel
  • TargetCursor
  • Cubes
  • Tilt
  • BorderGlow
  • GlassIcons
  • GlassSurface
  • Lanyard
  • ModelViewer
  • FluidGlass

FlickeringGrid

flickering-grid

Animates random grid-cell opacity to create a flickering technical backdrop.

Usage

Basic usage

Put it into the relative + overflow-hidden container and fill it with absolute inset-0; the theme foreground color is used by default, and the 4px squares flash randomly.

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid className="absolute inset-0" />
</div>

Custom color

color supports the CSS variable, passing the highlighted color token and raising the maxOpacity to make the grid more eye-catching.

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid className="absolute inset-0" color="var(--color-primary)" maxOpacity={0.5} />
</div>

Square size and spacing

squareSize / gridGap determines the grid density, increase the grid + reduce flickerChance to get a steady large grid flash.

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid
    className="absolute inset-0"
    squareSize={8}
    gridGap={4}
    flickerChance={0.1}
    maxOpacity={0.4}
  />
</div>

High frequency intensive flashing

Small square + high flickerChance simulates data flow/cyber texture.

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid
    className="absolute inset-0"
    squareSize={2}
    gridGap={2}
    flickerChance={0.7}
    maxOpacity={0.25}
  />
</div>

When to Use

Use it when you need a pixel grid background with a sense of technology/data, and the grid randomly flashes on and off. Based on Canvas, it comes with a ResizeObserver that follows the container size; if you want a static regular grid (no flickering, lighter), use GridPattern; if you want a dot matrix, use DotPattern; if you want a retro perspective grid, use RetroGrid.

Import

ts
import { FlickeringGrid } from "@hulianui/ui"

Props

Inherits HTMLAttributes<HTMLDivElement>, additionally:

NameTypeDefaultDescription
squareSizenumber4Side length of each square (px), the smaller, the denser
gridGapnumber6Square spacing (px)
flickerChancenumber0.3Flash probability per frame per frame (multiplied by deltaTime). 0=static mesh, 1=high frequency flashing
maxOpacitynumber0.3Maximum opacity of the grid (0~1), the higher the value, the more obvious
colorstring--color-foregroundSquare color; accepts any CSS color. When omitted, RGB is derived from the container's color value or token and follows the active theme.
widthnumber-Fixed width (px). Do not pass ResizeObserver to follow the container width
heightnumber-Fixed height (px). Do not pass ResizeObserver to follow the height of the container

Usage Guidelines

  • Based on Canvas, client rendering is required; the parent container needs relative + overflow-hidden, and the component itself is filled with absolute inset-0.
  • When width or height is omitted, a ResizeObserver tracks the container. Ensure the container has measurable dimensions and its height does not collapse to 0.
  • color can pass var(--color-*), and the component will getComputedStyle parsed frame by frame (different from Particles that only eat rgb), but there is a small cost for parsing each frame.

Related

DotPattern · GridPattern · StripedPattern · Spotlight · RetroGrid · Ripple

Playground

<div className="relative h-48 w-80 overflow-hidden rounded-xl">
  <FlickeringGrid
    className="absolute inset-0"
    squareSize={4}
    gridGap={6}
    flickerChance={0.3}
    maxOpacity={0.3}
  />
</div>
PreviousParticlesDecorationNextWavyBackground

On this page

  • Usage
  • Documentation
    • When to Use
    • Import
    • Props
    • Usage Guidelines
    • Related
  • Playground