Backgrounds

Animated Grid Pattern

A faint lattice with squares that light up at random.

The Animated Grid Pattern draws a dashed grid as a single SVG pattern, then scatters a handful of squares across the same lattice. Each square pulses on its own delay, so the surface never looks like it is running one loop.

Squares are placed on the grid's own coordinates, which means a pulse always lands inside a cell instead of straddling a stroke. The layout is rebuilt whenever the container resizes.

Usage

Animated Grid

Squares light up at random across a faint lattice

<template>
  <div class="relative h-64 w-full overflow-hidden rounded-xl border border-default bg-default">
    <MAnimatedGridPattern
      :num-squares="40"
      :duration="4"
      class="[mask-image:radial-gradient(320px_circle_at_center,white,transparent)]"
    />
    <div class="relative z-10 flex h-full flex-col items-center justify-center gap-2 text-center">
      <h3 class="text-2xl font-bold text-highlighted">
        Animated Grid
      </h3>
      <p class="max-w-xs text-sm text-muted">
        Squares light up at random across a faint lattice
      </p>
    </div>
  </div>
</template>

Examples

Customize

Customize

Color
Duration4
Height40
Max Opacity0.5
Num Squares50
Stroke Dasharray0
Width40
X-1
Y-1

Props

Prop Type Default Description
widthnumber40Cell width, in pixels.
heightnumber40Cell height, in pixels.
numSquaresnumber50How many squares to scatter across the grid. Capped at the number of cells that fit.
durationnumber4Seconds for one pulse of a square.
maxOpacitynumber0.5Ceiling for a square's opacity.
colorstring'var(--ui-border)'Colour of the grid and the twinkling squares.
strokeDasharraystring'0'Dash pattern for the grid strokes. '0' draws solid lines.
xnumber-1Horizontal offset of the pattern origin.
ynumber-1Vertical offset of the pattern origin.
classstring''CSS classes to apply to the <svg>. The element is absolutely positioned, so give the parent a height.

UI

This component's theme exposes the slots below. Override any of them per instance with the ui prop, or app-wide under ui.animatedGridPattern in app.config.ts.

Prop Type Default Description
uiobject-Per-slot classes merged over the theme defaults.
Slot Props Description
root-animated-grid-pattern pointer-events-none absolute inset-0 h-full w-full
grid-fill-transparent
squares-overflow-visible
square-animated-grid-pattern-square
Copyright © 2026