Skip to content
animorio
IT
Back to the library

Glass block background

Backgrounds, HoverGSAP, WebGL, CSS onlyAdvancedCompressed weight: Demo 9.4 KBGSAP 28 KBFreeDownload the zip

A page background to put behind a headline, on warm white: a wall of glass blocks, square glass bricks with light grout, in front of a soft apricot and lilac gradient. Each block is a pillow lens that turns its piece of the gradient over and squeezes it, with a thread of colour dispersion at the edge; the pointer carries a warm light that the wall breaks into a grid of small suns, and the blocks nearby swell a little. Press the button and a wave runs across the wall; when nobody touches, the light strolls on its own. A hand-written WebGL shader.

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>
<!--
  "Glass block 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 glass block wall background that refracts the light as you pass</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>
  <!-- the hero of an invented daylight and interiors studio, Oriel, on warm white: behind the words a wall of glass
       blocks, and behind the wall a soft apricot and lilac gradient; every block turns its piece of the gradient over,
       the pointer carries a warm light that the wall breaks into a grid of small suns, and the blocks near it swell -->
  <main class="stage" data-stage>
    <canvas class="glass" data-glass aria-hidden="true"></canvas>
    <span class="veil" aria-hidden="true"></span>
    <span class="grain" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="pill" data-in>
        <span class="pill__tag">Oriel</span>
        <span class="pill__text">Daylight and interiors studio</span>
      </p>
      <h1 class="title" id="hero-title" data-in>Light, made<br>to measure</h1>
      <p class="lede" data-in>We plan windows, glass and lamps around the way the sun moves through your rooms.</p>
      <div class="actions" data-in>
        <button class="cta" type="button" data-cta>
          <span class="cta__shine" aria-hidden="true"></span>
          <span class="cta__face">
            <span class="cta__row" data-row>
              <span class="cta__label">Book a light survey</span>
              <svg class="cta__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.5M8.5 4 12.5 8l-4 4"></path></svg>
            </span>
            <span class="cta__row cta__row--done" data-done aria-hidden="true">
              <svg class="cta__check" viewBox="0 0 16 16" aria-hidden="true"><path data-tick d="M3.5 8.4 6.6 11.3 12.6 4.9"></path></svg>
              <span class="cta__label">Request sent</span>
            </span>
          </span>
        </button>
        <span class="note">Replies within a day</span>
      </div>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 20 20" aria-hidden="true"><path d="M4 2.5v13.2l3.5-3.3 2.4 5.3 2.3-1-2.4-5.2 4.8-.2z"></path></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.

26 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 “Glass block 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

The first screen of an invented daylight and interiors studio, Oriel, on warm white: a pill «Oriel · Daylight and interiors studio», the big two-line headline «Light, made to measure», a softer line of text and the dark button «Book a light survey» with «Replies within a day» beside it. Behind it there is a wall of glass blocks: on arrival you only see the gradient, an apricot cloud at the top left and a lilac one at the bottom right; then the blocks rise from the top left corner to the bottom right one, each with a small overshoot and its settle, and the light grout draws itself between them. Each block turns over and squeezes the piece of gradient behind it, with a ring ripple like pressed glass and the colours parting slightly at the edge; the top left edge catches the light, the bottom right one casts a shadow on the grout. The warm light follows the pointer on a spring: the wall breaks it into a grid of small suns, and the blocks nearby swell and light up the edge that faces it. On the button the light gathers, a warm blade crosses it and the arrow jumps forward; pressed, it squashes and springs back, a wave leaves the button and runs across the whole wall, and the label turns into «Request sent» with a check that draws itself, then goes back. When nobody touches, the light strolls slowly on its own, and now and then a drawn pointer passes and presses the button.

How it works

One triangle covering the page

The WebGL canvas draws a single triangle bigger than the screen: all the work is in the fragment shader, which for every pixel works out which block it falls in and where inside the block, from minus a half to plus a half on both axes, with the grid centred on the page.

The block as a lens

Each block does not show what is behind it but samples it shifted by its position inside the block times REFRACT: above one the piece of gradient turns over and squeezes. Red and blue are read with a slightly different refraction, and a sine on the distance from the centre gives the ring ripple of pressed glass.

The pillow and the grout

The block is a rounded square inside the grout: the normal is a soft dome plus a steep bevel, a fixed light from the top left lights one side and a specular glint faces the pointer’s light. The grout is matte and light, with each block’s shadow shifted to the bottom right.

The light and the swell

The warm light is a bell plus a bright core, behind the glass, and follows the pointer on a hand-written spring. Near it a Gaussian bell magnifies the coordinates, so the blocks look bigger, and the refraction and the curve grow with SWELL.

The button’s wave

The click starts a ring from the centre of the button: its radius grows to the page’s diagonal while its strength fades, and where it passes the blocks shift, swell and light their glint. Meanwhile the label rises and gives way to «Request sent», with a check that draws itself, and comes back after 2.6 seconds.

The entrance and the stroll

On arrival a single number goes from zero to one in 2.2 seconds, and each block reads a piece of it according to its distance from the top left corner, with a back-style overshoot. When nobody touches, the light follows a slow figure made of four sines; after AUTO_PILOT seconds a drawn pointer passes, and the first real movement stops it.

Values to change

NameFileDefaultWhat it changes
BLOCKscript.js64Side of one glass block, in pixels (never more than a fifth of the short side).
JOINTscript.js2.5Half width of the grout between the blocks, in pixels.
REFRACTscript.js1.75How much each block turns the gradient over and squeezes it (0 flat glass).
SWELLscript.js0.8How much the blocks near the pointer swell (0 not at all).
GLOWscript.js1How strong the warm light is (0.3 to 2).
WANDERscript.js1How far the light strolls when nobody touches (0 still).
FOLLOWscript.js0.9How closely the light follows the pointer (0 not at all, 1 fully).
AUTO_PILOTscript.js3After how many seconds without a pointer the drawn one passes (0 never).
--tint-a / --tint-b / --hotstyle.css#ff9566 / #a596ff / #ffb36eThe two colours of the gradient behind the wall and the pointer’s warm light.

Try them in the Playground

When to use it

For the header of an architecture or interiors studio, a furniture or lighting brand, a design hotel or a launch page: when you need a light background with material and light that stays behind the headline without stealing the show.

On phones

Same animations: the block is never more than a fifth of the short side, so on a phone the wall still reads as a wall; the light follows the finger and the button starts the wave; headline, text and button fit inside the box, sized on the height too.

With reduced motion

With reduced motion the wall and the light are already in place, still, the words only fade in and the button changes its label without the wave.

Pitfalls

  • On a light background a white light does not show: the pointer’s light is a warm orange with a nearly white core, and the gradient stays away from the centre, where the words are.
  • A block as wide as a phone screen no longer looks like glass blocks: the side stops at a fifth of the page’s short side.
  • The grout and the bevel must be tied to the entrance: with the grout already drawn over the flat gradient you see a grid before the glass.
  • gl_FragCoord starts from the bottom: the pointer, the clouds and the wave must be passed with y flipped and in device pixels.
  • Without WebGL the CSS background remains: the two radial clouds under a grid of white lines.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 7 November 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