beta

Grid Pattern — <mv-grid-pattern>

Pure-CSS background grid (solid or dashed lines, highlighted cells, radial fade) plus an animated element: flicker, cells that light up under the cursor with a trail and a ripple on click, and a retro perspective floor.

CategoryBackgrounds
TypeWeb Component (<mv-grid-pattern>)
Statusbeta
Keywordsgrid, pattern, flicker, retro, interactive, hero, canvas

When to use

Avoid when

Install

node scripts/add.mjs grid-pattern --out ./src/marvelous

AI agent with the Marvelous UI MCP server: install_components({ slugs: ["grid-pattern"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

Files copied (dependencies included): tokens/tokens.css, core/base.css, core/canvas.js, core/dom.js, core/element.js, core/motion.js, core/pointer.js, components/grid-pattern/grid-pattern.css, components/grid-pattern/grid-pattern.js.

Usage

Canonical markup — start from it and customize with attributes, data-* and CSS variables:

<div style="display:grid;grid-template-rows:320px 180px">
  <section style="position:relative;display:grid;place-items:center;text-align:center;overflow:hidden;padding:2rem">
    <mv-grid-pattern variant="interactive" data-fill></mv-grid-pattern>
    <div style="position:relative">
      <p style="margin:0;font:700 clamp(1.6rem,4vw,2.6rem)/1.1 var(--mv-font-sans);letter-spacing:-.03em">Every cell responds to your cursor</p>
      <p style="margin:.6rem auto 1.2rem;max-width:32rem;color:var(--mv-fg-muted)">Hover to leave a trail, click to send a ripple.</p>
      <a class="mv-button" href="#grid-pattern">Explore the grid</a>
    </div>
  </section>
  <div style="display:grid;grid-template-columns:repeat(3,1fr);border-top:1px solid var(--mv-border)">
    <div class="mv-grid-pattern" data-variant="dashed" data-animate style="display:grid;place-items:center;--mv-grid-pattern-size:32px">
      <div class="mv-grid-pattern-cells" aria-hidden="true"><i style="--x:4;--y:1"></i><i style="--x:9;--y:2"></i><i style="--x:6;--y:3"></i><i style="--x:12;--y:1"></i><i style="--x:2;--y:3"></i><i style="--x:10;--y:4"></i></div>
      <strong style="font-size:.9rem">CSS · dashed</strong>
    </div>
    <div style="position:relative;display:grid;place-items:center;overflow:hidden;border-inline:1px solid var(--mv-border)">
      <mv-grid-pattern variant="flicker" data-fill></mv-grid-pattern>
      <strong style="position:relative;font-size:.9rem">Flicker</strong>
    </div>
    <div style="position:relative;display:grid;place-items:center;overflow:hidden">
      <mv-grid-pattern variant="retro" data-fill></mv-grid-pattern>
      <strong style="position:relative;font-size:.9rem;align-self:start;margin-top:1.4rem">Retro</strong>
    </div>
  </div>
</div>

API

Attributes

NameTypeDefaultDescription
variantflicker | interactive | retro<mv-grid-pattern>: animated variant (no value: CSS grid).
data-variantdashedDashed lines (class or element).
data-faderadial | top | bottom | edges | noneradialFade mask.
data-animatebooleanCSS class: highlighted cells pulse in a staggered way.
data-fillbooleanFills the positioned parent (absolute, inset 0).
squaresnumberDefault variant: N random cells that appear, then move around.
sizenumber4 (flicker) / 40 (interactive)Cell size in px.
gapnumber6flicker: spacing between cells.
colorCSS colorvar(--mv-accent)Cell color (tokens accepted, follows the theme).
max-opacitynumber0.4flicker: maximum opacity.
chancenumber0.3flicker: probability of change per cell per second.
trailnumber0.9interactive: trail duration in seconds.
ambient"false"interactive: disables cells that light up on their own.

CSS classes

NameDescription
mv-grid-patternCSS grid layer (no JS). data-fill fills a positioned parent.
mv-grid-pattern-cellsContainer for highlighted cells; each child is placed via style="--x:3;--y:1".

CSS variables

NameDefaultDescription
--mv-grid-pattern-size40pxGrid step (56px for retro).
--mv-grid-pattern-stroke1pxLine thickness.
--mv-grid-pattern-colorfg 11%Line color.
--mv-grid-pattern-cellaccent 18%Highlighted cell color (CSS).
--mv-grid-pattern-dash4pxDash length.
--mv-grid-pattern-x / -y0pxGrid offset.
--mv-grid-pattern-maskCustom mask (overrides data-fade).
--mv-grid-pattern-angle68degretro: floor tilt.
--mv-grid-pattern-speed1.4sretro: time to travel one cell.

Accessibility

Purely decorative: aria-hidden, pointer-events: none with data-fill (the interactive variant listens on the parent). Reduced motion: grid and cells are static, highlighting is instant with no trail.