Skip to content

Grid Background

Section background: a ruled grid drawn with the DA stroke color that drifts diagonally, solid color blocks that blink in hard steps, and an optional SVG grain layer. Wraps any content.

brutalist/effect/grid-background
Open ↗

Source

"use client";

import type { ReactNode } from "react";
import { motion, useReducedMotion } from "motion/react";
import { cn } from "@/lib/utils";

export interface GridBackgroundProps {
  children?: ReactNode;
  /** Grid cell size in px. */
  cell?: number;
  /** Seconds for the grid to drift by one cell (0 disables the drift). */
  speed?: number;
  /** Solid squares that blink on the grid. */
  blocks?: number;
  /** Adds an SVG grain layer. */
  noise?: boolean;
  className?: string;
}

// Deterministic pseudo-random positions so server and client render the same thing.
function blockPositions(count: number): { x: number; y: number; tone: number; delay: number }[] {
  return Array.from({ length: count }, (_, i) => ({
    x: (i * 37 + 11) % 97,
    y: (i * 53 + 7) % 89,
    tone: i % 3,
    delay: (i * 0.7) % 4,
  }));
}

const TONES = ["bg-da-primary", "bg-da-accent", "bg-da-secondary"];

const NOISE =
  "url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>\")";

export function GridBackground({ children, cell = 48, speed = 6, blocks = 7, noise = true, className }: GridBackgroundProps) {
  const reduce = useReducedMotion();
  const animate = !reduce && speed > 0;

  return (
    <div className={cn("relative isolate overflow-hidden bg-da-bg text-da-fg", className)}>
      <motion.div
        aria-hidden
        className="absolute -inset-px -z-10 opacity-25 [background-image:linear-gradient(var(--da-border)_2px,transparent_2px),linear-gradient(90deg,var(--da-border)_2px,transparent_2px)]"
        style={{ backgroundSize: `${cell}px ${cell}px` }}
        animate={animate ? { backgroundPosition: ["0px 0px", `${cell}px ${cell}px`] } : undefined}
        transition={animate ? { duration: speed, ease: "linear", repeat: Infinity } : undefined}
      />
      <div aria-hidden className="absolute inset-0 -z-10">
        {blockPositions(blocks).map((b, i) => (
          <motion.span
            key={i}
            className={cn("da-stroke absolute", TONES[b.tone])}
            style={{ left: `${b.x}%`, top: `${b.y}%`, width: cell, height: cell }}
            initial={{ opacity: 1 }}
            animate={reduce ? undefined : { opacity: [1, 1, 0, 0, 1] }}
            transition={reduce ? undefined : { duration: 4, delay: b.delay, repeat: Infinity, ease: "linear", times: [0, 0.5, 0.5, 0.75, 0.75] }}
          />
        ))}
      </div>
      {noise && <div aria-hidden className="pointer-events-none absolute inset-0 -z-10 opacity-20 mix-blend-multiply" style={{ backgroundImage: NOISE }} />}
      {children}
    </div>
  );
}

export default GridBackground;

modules/brutalist/effect/grid-background/index.tsx

Props

PropTypeDefaultDescription
childrenReactNode—Content rendered above the background.
cellnumber48Grid cell size (px); blocks use the same size.
speednumber6Seconds to drift one cell; 0 = static.
blocksnumber7Number of blinking color blocks.
noisebooleantrueSVG grain overlay.
classNamestring—Classes on the wrapper (set height/padding here).

Other background variants in Brutalist

Background in other art directions

Animated

Blobs Background

Three large gradient blobs that continuously morph their border-radius, rotate and drift, optionally seen through a heavy frosted pane for a true glassmorphism backdrop. Pure CSS.

GlassBackground
Animated

Bubbles Background

Translucent glass bubbles with specular highlights and luminous rims rising and swaying at varied sizes and speeds behind the content. Pure CSS.

GlassBackground
Animated

Mesh Background

Living mesh gradient: four large SVG blobs (DA primary, accent + two hues) drifting slowly, merged by an SVG goo filter for a liquid feel, heavily blurred and grain-dithered. Wraps any content.

GlassBackground
Animated

Ribbons Background

Three wide, blurred SVG gradient ribbons (primary, accent, danger) flowing horizontally in slow sine waves, like silk behind frosted glass. Pure CSS animation.

GlassBackground
Animated

Aurora Background

Hero background with three heavily blurred color fields (indigo primary + cyan + violet) drifting slowly over a radially-masked hairline grid, fading into the page at the bottom.

MinimalBackground
Animated

Beams Background

Vertical hairline columns fading at top and bottom, with short primary-colored beams of light falling down some of them at staggered speeds. Pure CSS.

MinimalBackground
Animated

Dot Wave Background

Dot matrix, radially masked, across which a diagonal wave of slightly larger primary-colored dots ripples continuously like a heartbeat. CSS keyframes only.

MinimalBackground
Animated

Grid Glow Background

Hairline grid whose lines light up in the primary color inside a soft radial spotlight that follows the mouse (CSS variables updated on pointer move, no re-render), vignetted to the page color.

MinimalBackground
Animated

Crosshair Background

Measuring crosshair: full-width and full-height hairlines follow the pointer with live mono X/Y coordinates next to the intersection — a design-tool feel for hero areas. Mouse only; hidden otherwise.

Mono CleanBackground
Animated

Guides Background

Layout-grid backdrop: hairline column guides (like a design tool’s grid overlay) that draw in from top to bottom one after another, with tiny mono column numbers along the top. Pure CSS.

Mono CleanBackground
Animated

Halftone Background

Print-inspired halftone: a regular ink dot screen fading out across the section via a linear mask, like a newspaper gradient; static, pure CSS.

Mono CleanBackground
Animated

Word Background

A giant outlined word (hairline stroke, no fill) slowly drifting sideways behind content in an endless loop — typographic texture instead of imagery. Pure CSS.

Mono CleanBackground
Animated

Dot Matrix Background

Fine dot matrix in the border color; dots near the pointer light up in primary through a radial mask that follows the cursor (pointer devices only).

Neo CorporateBackground
Animated

Flow Lines Background

Horizontal “money flow” lines (smooth SVG curves in the border color) with small primary pulses travelling along them — evokes payment rails. SVG + CSS, static with reduced motion.

Neo CorporateBackground
Animated

Glow Background

Two large blurred primary/accent glows drifting slowly behind content, plus a thin horizon line — restrained corporate ambience. Pure CSS, static with reduced motion.

Neo CorporateBackground
Animated

Grid Background

Faint hairline grid in the border color, radially masked toward one edge, with a few cells softly pulsing in primary — the classic fintech hero backdrop. Pure CSS.

Neo CorporateBackground
Animated

Blob Background

Three soft organic blobs (sage, clay, sand) slowly morphing their border-radius and drifting behind content — a living, breathing backdrop. Pure CSS.

Organic SoftBackground
Animated

Hills Background

Layered rolling hills along the bottom in three sage tones, each layer drifting sideways at a different pace (gentle parallax), with an optional clay sun rising slowly.

Organic SoftBackground
Animated

Leaves Background

Leaves drifting down and swaying side to side behind content, in sage/clay tints with varied sizes, speeds and delays. Pure CSS; leaves rest in place with reduced motion.

Organic SoftBackground
Animated

Paper Background

Recycled-paper surface: the cream background with a fine SVG turbulence grain and a soft warm vignette — static texture that makes flat sections feel tactile.

Organic SoftBackground
Animated

Confetti Background

Festive background of flat pastel confetti (dots, pills, squares) drifting down slowly with a gentle spin — for success, onboarding-complete and celebration pages.

Soft FlatBackground
Animated

Polka Background

Soft polka-dot pattern (two offset grids) in a pastel tone, drifting diagonally, with an optional clear center so content stays readable. CSS only.

Soft FlatBackground
Animated

Shapes Background

Calm background of big flat pastel shapes (circles, pills, rounded squares) floating slowly up and down at different phases. Pure CSS.

Soft FlatBackground
Animated

Waves Background

Three layered flat pastel waves (lavender, mint, peach) along the bottom of a section, each drifting sideways at its own pace. SVG + CSS.

Soft FlatBackground