Skip to content
animorio
IT
Back to the library

Glow grid background

Backgrounds, HoverGSAP, CanvasMediumCompressed weight: Demo 6.8 KBGSAP 28 KBFreeDownload the zip

An animated background to put behind a product hero, on near black: a grid of hairline squares, 48 pixels each, that lights up in a violet blue around the pointer with a light that fades with the radius. The cells the light crosses fill faintly and fade slowly like a trail, a tap lights the grid in rings, and now and then a ray runs along a line from one edge to the other.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Glow grid background" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The grid background that lights up around the pointer</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage" data-stage>
    <!-- the background: a grid of very thin lines on near black, lit by one soft light around the pointer,
         with cells that fill faintly and fade like a trail, and now and then a ray running along a line -->
    <canvas class="grid" data-grid aria-hidden="true"></canvas>
    <div class="vignette" aria-hidden="true"></div>

    <section class="hero">
      <a class="pill" href="#" data-pill>
        <span class="pill__tag">New</span>
        <span class="pill__text">Linthal 2.0 is live</span>
        <svg class="pill__chev" viewBox="0 0 16 16" aria-hidden="true"><path d="m6 4 4 4-4 4"/></svg>
      </a>
      <h1 class="title">Build on a grid<br>that answers back</h1>
      <p class="lead">Linthal turns your design tokens into a live layout system the whole team can trust.</p>
      <div class="actions">
        <a class="btn btn--primary" href="#" data-btn>
          <span>Start building</span>
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h8.5M8.5 4.5 12 8l-3.5 3.5"/></svg>
        </a>
        <a class="btn btn--ghost" href="#">Read the docs</a>
      </div>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 12l-6.3 1.5-3.4 5.8z"/></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

20 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Glow grid background” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a near black background sits the hero of a made-up product, Linthal: a pill New · Linthal 2.0 is live, the headline Build on a grid that answers back on two lines, a grey line and two buttons, a light Start building and an outlined Read the docs. Behind it, a grid of hairline squares, 48 pixels each, centred on the page and fading towards the edges. Around the pointer the grid lights up: a single light, about 230 pixels wide, follows the pointer with a small lag, and under it the lines turn a violet blue that fades with the radius, over a very wide faint veil of colour. The cells the light crosses fill faintly with their border lit, plus a fainter neighbour, then fade in a little over a second: a trail of squares stays behind the pointer. Over the button the light widens a little. A tap or a click lights the grid in chessboard rings starting from that point. Every two or three seconds a ray, a stroke of light with a tail, runs along a grid line from one edge to the other. In the autopilot a drawn pointer goes round the page, moves onto the button and presses it.

How it works

Two grids drawn once

On every resize the script draws the grid twice into two offscreen canvases: an unlit one, with white lines at 5%, and a lit one, with the same lines in the light colour. The grid is centred: a line always crosses the centre of the page, so it is symmetric on every screen.

The light, cut out

Every frame the main canvas copies the unlit grid; then in a third canvas the lit grid is cut by a round gradient with destination-in, and only that circle of lit lines is laid on top. Underneath, a very wide and faint veil of colour.

The soft lag

Every frame the light covers part of the remaining distance, 1 minus LIGHT_LAG raised to the elapsed time, so the lag is the same at 60 and 120 frames per second. The clock is GSAP’s ticker.

The trail and the ripple

Each cell holds a number, its energy. When the light enters a new cell its energy goes to 1 and a neighbour’s to 0.5; every frame the energy drops and the cell is drawn with a fill of the energy squared and a border in proportion. A tap lights the cells in rings by chessboard distance, fourteen rings a second.

The rays

Every RAY_EVERY seconds, with a little randomness, a ray is born on a random horizontal or vertical line: a 200 pixel segment with a linear gradient from transparent to the light colour at its head, and a 3 pixel halo on the last 50. It runs at RAY_SPEED pixels a second and disappears past the edge.

Values to change

NameFileDefaultWhat it changes
CELLscript.js48The side of the grid squares, in pixels.
LIGHT_RADIUSscript.js230How wide the light around the pointer is, in pixels.
LIGHT_LAGscript.js0.88How far the light lags behind the pointer (0 = it follows at once).
LINE_GLOWscript.js1How bright the lines under the light get.
TRAILscript.js1.4How many seconds the trail cells take to fade.
TRAIL_FILLscript.js0.14How much the trail cells fill.
RAY_EVERYscript.js2.6How many seconds between rays running along a line (0 = never).
RAY_SPEEDscript.js900How fast the ray runs, in pixels per second.

Try them in the Playground

When to use it

Behind the hero of a software product, a developer tool, an AI app or a tech event page on a dark background: the grid says precision and the light shows the page responds, without getting in the way of the headline.

On phones

The same grid with touch instead of hover: the light goes where you tap and follows as the finger moves, and every tap lights the rings. Headline and buttons are sized on the height too, so they fit in the box.

With reduced motion

No chasing, trail, ripples or rays: the light appears still around the button and fades in; if the pointer moves, the light goes there at once with no lag.

Pitfalls

  • Redrawing every line each frame is costly: draw them once into two offscreen canvases and copy them each frame, cutting the lit one with destination-in in a third canvas.
  • Lines must sit on half pixels (Math.round plus 0.5), or at density 1 they turn two pixels wide and blurry.
  • A lag with a fixed number per frame runs twice as fast at 120 Hz: it must be raised to the elapsed time.
  • On resize the canvas and both offscreen canvases must be rebuilt with the pixel density and the grid re-centred, or the light and the cells no longer match the lines.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.8 KB; the libraries: GSAP 28 KB.

Testing

Tested on 25 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations