Skip to content
animorio
IT
Back to the library

Breathing gradient

Backgrounds, WebGLGSAP, WebGL, CSS onlyMediumCompressed weight: Demo 6.8 KBGSAP 28 KBFreeDownload the zip

An animated background for an app’s hero: a soft mesh gradient of four close colours, peach, pink, lilac and cream, drifting slowly while swelling and settling like a breath, with a fine grain that removes the banding. The field bends towards the pointer as if under a lens, and the button, when pressed, sends a soft wave through the colour. One WebGL shader, in the Morphin style.

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>
<!--
  "Breathing gradient" 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 breathing gradient background</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 app, Nimbra, over a soft mesh gradient that breathes: four close colours that swell and
       settle on a slow cycle, a fine grain on top, the field bending a little towards the pointer and a soft wave
       running through the colour when the button is pressed -->
  <main class="stage" data-stage>
    <canvas class="field" data-field aria-hidden="true"></canvas>
    <span class="grain" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="pill" data-in>
        <span class="pill__tag">Beta</span>
        <span class="pill__text">Nimbra 2 is open</span>
        <svg class="pill__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 10.5 8 6 12.5"></path></svg>
      </p>
      <h1 class="title" id="hero-title" data-in>Plan the week<br>without the noise</h1>
      <p class="lede" data-in>Nimbra gathers your tasks, calls and notes into one quiet list that breathes with your day.</p>
      <div class="actions" data-in>
        <button class="cta" type="button" data-cta>
          <span class="cta__shine" aria-hidden="true"></span>
          <span class="cta__label">Get early access</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>
        </button>
        <span class="note">Free for teams of five</span>
      </div>
    </section>
  </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.

23 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 “Breathing gradient” 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 app for planning the week, Nimbra: in the middle a pill «Beta · Nimbra 2 is open», the big two-line headline «Plan the week without the noise», a grey line and the black button «Get early access» with «Free for teams of five» beside it. Behind it, across the whole page, a soft gradient of four close colours, peach, pink, lilac and cream, one in each corner, blending without edges and drifting slowly around their places. Every seven seconds the field takes a breath: the patches of colour widen a little and the light rises by a hair, then they settle. In the middle, where the words are, the colour is lighter. On top sits a fine paper-like grain that removes the banding of the gradients. The pointer bends the colour towards itself like a lens, with a little lag. Pressing the button, it squashes and springs back, the arrow jumps forward, and a soft wave starts from the button and runs through all the colour, lightening it as it passes. If nobody touches it, every nine seconds the button presses itself.

How it works

One triangle, one shader

A WebGL canvas behind the hero with one triangle covering the whole screen; pixel density is capped at 1.5. Every pixel computes its colour in the fragment shader: no images, no textures.

Four weighted colours

The four colours sit at four points near the corners and drift on small slow orbits. Every pixel takes the average of the colours weighted by a Gaussian of the distance: near a point its colour wins, in between they blend. A light wave warps the space, so the borders never look like circles.

The breath

The radius of the Gaussians grows and shrinks on a cosine BREATH seconds long, by DEPTH: the patches widen and narrow all together. At the same time the light rises and falls by a hair. In the middle, where the words are, the colour is lighter.

The lens and the wave

The pointer pulls the space towards itself with a narrow Gaussian, followed with a soft lag. The button’s wave is a ring growing from 0 to 2.2 in 2.6 seconds with power2.out: where it passes it pushes the colour outwards and lightens it, fading as it goes.

The grain

A noise that changes every frame, of strength GRAIN, over the colour, plus a still SVG grain in soft-light over everything: wide gradients do not band even on 8-bit screens.

Values to change

NameFileDefaultWhat it changes
BREATHscript.js7How many seconds a whole breath of the gradient lasts.
DEPTHscript.js0.16How much the colour swells at each breath.
DRIFTscript.js1How much the colours drift around their places (0 stops them).
GRAINscript.js0.045How much grain over the gradient.
POINTERscript.js0.6How much the field bends towards the pointer.
WAVEscript.js1How strong the wave from the button is.
AUTO_PRESSscript.js9Every how many seconds the button presses itself when nobody touches (0 never).

Try them in the Playground

When to use it

As the background of the first screen of an app or software, a wellbeing product, a waitlist or a launch: it gives the hero colour and life without stealing the scene from the headline and the button.

On phones

The same gradient with adapted sizes: the colours sit in the corners of the tall narrow page, the headline goes on two smaller lines, and the finger bends the colour like the pointer; tapping the button sends the wave.

With reduced motion

The gradient stands still: no breath, no drift and no lens. Pressing the button the colour only lightens for a moment around it, with no travelling wave; the words are already in place.

Pitfalls

  • Wide light gradients on an 8-bit screen show visible bands: the grain in the fragment shader breaks them, and at 0.045 it does not read as dirt.
  • The shader’s time comes from GSAP’s ticker and not from performance.now(): this way the preview bench controls it and the video is always the same.
  • The button’s position for the wave is measured at the moment of the press: with resize the demo window changes height and the button moves.
  • The canvas density is capped at 1.5: at 3 on phones the shader costs nine times as much with no visible difference on such a soft colour.

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