StealThis .dev

Animated Grid Pattern

An SVG grid pattern with randomly highlighted cells that pulse and glow, perfect for dark hero sections and backgrounds.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Animated Grid Pattern

A mesmerizing SVG grid pattern where cells randomly highlight with a soft glow animation. Ideal as a subtle animated background for hero sections, dashboards, or landing pages.

How it works

  1. An SVG grid of rectangles is generated programmatically
  2. JavaScript randomly selects cells at intervals and adds a highlight class
  3. CSS keyframe animations handle the glow-in and fade-out transitions
  4. A radial gradient mask fades the grid edges for a polished look

Customization

  • Adjust COLS, ROWS, CELL_SIZE, and GAP to change the grid density
  • Modify the highlight color via the --glow-color CSS variable
  • Control animation speed with --glow-duration and the JS interval timing

When to use it

  • Hero section backgrounds
  • Behind pricing or feature cards
  • Dashboard ambient backgrounds
  • Landing page visual accents