Skip to content
animorio
IT
Back to the library

Soap film background

Backgrounds, WebGL, HoverWebGL, GSAP, CSS onlyAdvancedCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

An animated background for the opening of an AI app, Nacre: behind the headline and the prompt field a soap film is stretched over the dark page, and a soft light reflected in it shows its colours, which come from the thickness of the film as in a real bubble. The film drains slowly and breathes by itself; where the pointer passes the soap swirls into eddies and thins; sending the prompt sends a ring out from the field that runs every colour through to the edges. 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>
<!--
  "Soap film 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 iridescent soap film background the pointer swirls behind the prompt</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 opening screen of an invented AI app, Nacre, over a soap film stretched across the dark page: a soft light
       reflected in it shows the colours of the film, which drain slowly downwards and swirl where the pointer passes;
       sending the prompt sends a thinning ring through the film, so the colours ripple out from the field -->
  <main class="stage" data-stage>
    <canvas class="film" data-film 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">Nacre 2</span>
        <span class="pill__text">Now with live canvas</span>
      </p>
      <h1 class="title" id="hero-title" data-in>What shall we<br><em>make today?</em></h1>

      <form class="prompt" data-prompt data-in autocomplete="off">
        <span class="prompt__rim" aria-hidden="true"></span>
        <label class="sr" for="ask">Ask Nacre</label>
        <input class="prompt__input" id="ask" data-input type="text" placeholder="Ask Nacre to draft, plan or design" spellcheck="false">
        <div class="prompt__bar">
          <button class="tool" type="button" aria-label="Attach a file">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.6 4.6 5.4 9.8a1.6 1.6 0 0 0 2.3 2.3l5.4-5.4a3 3 0 0 0-4.2-4.2L3.5 7.9a4.3 4.3 0 0 0 6.1 6.1l4.1-4.1"></path></svg>
          </button>
          <span class="model">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1.8c.5 3.2 2 4.7 6.2 6.2-4.2 1.5-5.7 3-6.2 6.2C7.5 11 6 9.5 1.8 8 6 6.5 7.5 5 8 1.8z"></path></svg>
            <span>Nacre 2</span>
          </span>
          <span class="status" data-status aria-live="polite"></span>
          <button class="send" type="submit" data-send aria-label="Send">
            <span class="send__ring" aria-hidden="true"></span>
            <svg class="send__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 12.8V3.6M4.2 7.2 8 3.4l3.8 3.8"></path></svg>
            <svg class="send__tick" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.8 8.4 6.7 11.2 12.3 5"></path></svg>
          </button>
        </div>
      </form>

      <div class="chips" data-in>
        <button class="chip" type="button" data-chip="Draft a launch note for our spring drop">Write</button>
        <button class="chip" type="button" data-chip="Plan a three-day trip to Lisbon">Plan</button>
        <button class="chip" type="button" data-chip="Design a calm onboarding for a sleep app">Design</button>
      </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.

25 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 “Soap film 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 AI app, Nacre, on an almost black page: a pill «Nacre 2 · Now with live canvas», the big Mona Sans headline «What shall we make today?» with the last words slowly carrying the colours of the film, the dark glass prompt field with a one-pixel rim that catches the light where the pointer is, the paperclip, the «Nacre 2» model, the white send button, and below three pills Write, Plan and Design. Behind it a soap film is stretched across the whole page: the shader works out the thickness of the film in nanometres and, for seven wavelengths, how much light bounces between its two faces, so the colours are those of a real bubble, gold, magenta, blue and green in bands that follow each other. The film drains downwards: thin and vivid at the top, thicker and paler at the bottom, and slow currents marble it. It only shows where a soft light, like a reflected window, falls on it: above the headline, drifting slowly and breathing; behind the words the light dims so they read. On arrival the light comes down from the top on a spring and the words rise one after another with a one-pixel settle. Where the pointer passes the soap swirls into eddies in the way it moves, which wind up and relax in a few seconds, the film under it thins towards gold and the light leans towards it. A pill types its prompt into the field; Enter or the button: the button squashes and springs back, the arrow leaves upwards, a ring in the colours of the film turns around it while «Thinking» shimmers, and in the film a ring runs out from the field, thinning it and running every colour through to the edges; then the tick draws itself, «Draft ready», and the field empties. With the field empty, the field shakes no twice. If nobody moves the pointer, a drawn one stirs the film, types a prompt and sends it.

How it works

One triangle covering the page

The WebGL canvas draws a single triangle bigger than the screen, at a little under one pixel per CSS pixel; the shader works out the whole film, pixel by pixel.

The thickness of the film

For every pixel a thickness in nanometres: thinner at the top and thicker at the bottom, like a draining film, plus a fractal noise warped by another noise that flows with time, so the film marbles by itself. THICKNESS multiplies it.

The real colours of a bubble

Light bounces off the two faces of the film and the two waves meet out of phase by 4π·n·d/λ: for seven wavelengths between 430 and 670 nm the shader adds sin² of half the phase, weighted with its colour. Where the film is thick the colours wash out to a pearly white, where it is very thin it goes towards gold and black.

The reflected light

The film only shows where a light falls on it: a soft elliptical window above the headline, LIGHT_SIZE big, which breathes and wanders on a spring, plus a veil of light everywhere and a light thread on the window's edge. Behind the headline the light dims so the words read.

The pointer's eddies

The pointer leaves a trail of 16 points, each with its moment and its direction (which way the path turns). Every point rotates the film's coordinates around itself with a Gaussian: the angle grows and then fades in SETTLE seconds, so the eddy winds up and relaxes. SWIRL multiplies it.

Sending

Sending the prompt sends a ring from the field out to the edges, thinning the film as it passes, so every colour runs through it; the button goes from the arrow to the turning ring of colours and to the tick, and the label from «Thinking» to «Draft ready». After AUTO_PILOT seconds without a pointer, a drawn one does it all again.

Values to change

NameFileDefaultWhat it changes
THICKNESSscript.js1How thick the film is (lower: brighter colours, down to black).
SWIRLscript.js1How much the pointer swirls the soap (0 no eddies).
SETTLEscript.js4.2How many seconds the eddies take to relax.
DRAINscript.js1How fast the film drains and moves by itself.
LIGHT_SIZEscript.js1How big the light reflected in the film is.
SHEENscript.js1How bright the film is.
AUTO_PILOTscript.js4After how many seconds without a pointer the drawn one starts moving (0 never).

Try them in the Playground

When to use it

For the opening of an AI app, an assistant, a creative tool or a product landing page on a dark background: when you need a background that feels like a real material, light and liquid together, reacts to the pointer and to sending the prompt, and leaves the headline and the field in front.

On phones

Same animations: the film is sized on the short side of the screen, the finger swirls it like the pointer, headline, field and pills fit inside the box and the status label is short.

With reduced motion

With reduced motion the film is still, with its colours and light in place and no eddies; the words only fade in and sending shows the tick and «Draft ready» straight away.

Pitfalls

  • With the whole page lit the film becomes any old rainbow: it has to show only where a reflected light falls on it, with the rest left almost black, like a real bubble in front of a window.
  • A noise with too many octaves gives stepped edges and looks like a grainy oil stain: three octaves with a wide warp give the long smooth bands of soap.
  • The bands need contrast (a power on the colours) and a touch of desaturation, or the seven wavelengths blend into a pastel gradient that no longer looks like interference.
  • The eddy cannot keep turning forever: its angle grows and then fades with the point's life, or the film stays torn where the pointer passed.
  • Without WebGL the CSS background stays: three rose, mint and gold glows on black, which already look like a reflection on soap.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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