Skip to content
animorio
IT
Back to the library

Prism spectrum background

Backgrounds, HoverGSAP, Canvas, CSS onlyMediumCompressed weight: Demo 9.2 KBGSAP 28 KBFreeDownload the zip

An animated background for an AI app’s hero, on near black: a thin white beam comes in from above, crosses a small glass prism and opens into a soft spectrum, from red to violet, that fans down behind the headline to the floor. The fan breathes, turns towards the pointer on a spring and gathers into a bright focus on the button, leaving a ring of colour round its edge. In the Libraries.dev style: light as a material on a real piece of interface.

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>
<!--
  "Prism spectrum 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 background with a spectrum of light from a prism behind the headline</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 AI research app, Spectrel, on near black: a thin white beam comes in from above, crosses a
       small glass prism and opens into a soft spectrum that fans down behind the words to the floor; the fan turns after
       the pointer, breathes, and narrows into a bright focus when the pointer reaches the button -->
  <main class="stage" data-stage>
    <canvas class="light" data-light 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">New</span>
        <span class="pill__text">Spectrel now reads your whole drive</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 data-title>Every angle,<br>one answer</h1>
      <p class="lede" data-in>Ask one question. Spectrel splits it, reads every source and brings the light back together.</p>
      <div class="actions" data-in>
        <button class="cta" type="button" data-cta>
          <span class="cta__rim" aria-hidden="true"></span>
          <span class="cta__shine" aria-hidden="true"></span>
          <span class="cta__label">Ask Spectrel</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">50 questions a month, free</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.

21 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 “Prism spectrum 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 research app, Spectrel, on near black: a pill «New · Spectrel now reads your whole drive», the big two-line headline «Every angle, one answer», a grey line and the light button «Ask Spectrel» with «50 questions a month, free» beside it. On arrival a thin white beam comes in from the top left and hits a small glass prism hanging above the words; inside the glass the light bends, and out of the base comes the spectrum, opening with a small bounce, then the words rise one after another. The spectrum fans down behind the headline, made of many thin bands from red to violet, each shimmering slowly on its own, and settles on the floor in a pool of colour with a thin horizon line in the same colours. The fan breathes, the prism has sharp edges with a glint running slowly along them, and where the light leaves the glass there is a tiny line of colour. The fan turns towards the pointer on a spring and the prism turns with it; the headline splits slightly too, with a red thread on one side and a blue one on the other, wider when the light leans. When the pointer reaches the button the spectrum narrows into a brighter focus aimed at it, a light sweeps across the button and a ring of colour lights up round its edge, turning slowly. Pressed, the button squashes and springs back, the arrow jumps forward and the spectrum widens at once and comes back on a spring. If nobody moves the pointer, a drawn one moves around the page and presses the button.

How it works

The spectrum, small and blurred

The bands of the spectrum are drawn on a canvas at just over a fifth of the size, with a blur filter, then scaled up onto the big canvas in lighter mode: the colours melt into each other like real light and the work costs little even on a phone.

The bands of the fan

BANDS thin wedges all start from the same point on the base of the prism and reach the floor, each with its own angle and its own colour taken from seven stops between red and violet. Each band has a gradient fading downwards and a slow shimmer of its own; the middle ones are a little stronger.

The prism, sharp over the light

The prism is a triangle drawn on the big canvas, after the blurred light: faintly bright glass, the beam bending inside (cut to the triangle with a clip), three edges with three different lights and a glint running along them one after another. It turns with the fan, and the points where the light enters and leaves are worked out again every frame.

The springs and the focus

The turn of the fan, the focus on the button and the kick of a press are three hand-written springs. The breathing is the sum of two slow waves; on the button the opening narrows by FOCUS and the light rises, and the button’s ring of colour is a conic-gradient with a mask that leaves only the edge.

The entrance and the drawn pointer

On arrival the light rises, the spectrum opens out of the prism with a back.out and the words rise staggered. After a few seconds without a pointer a looping timeline moves a drawn pointer and presses the button; the first real movement stops it.

Values to change

NameFileDefaultWhat it changes
SPREADscript.js17How wide the fan of colours opens, in degrees on each side.
BANDSscript.js42How many bands the spectrum is split into (more bands, softer).
TILTscript.js10How many degrees at most the fan turns towards the pointer.
FOCUSscript.js0.6How much the fan narrows when the pointer is on the button (0 not at all, 1 fully).
BREATHscript.js1How much the spectrum breathes (0 still).
GLOWscript.js1How strong the light 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

As the background of the first screen of an AI app, a research or analysis tool, a product that brings many sources together, or a launch on a dark page: light that splits and gathers says on its own what the product does.

On phones

The same prism and the same spectrum with adapted sizes: the prism is smaller, the fan comes down the tall narrow page, the headline goes on two smaller lines and the finger turns the light like the pointer; tapping the button gathers the spectrum and widens it with the kick.

With reduced motion

The light is already in and the spectrum is already open and still: no breathing, no shimmer, no turning and no drawn pointer. On the button the spectrum narrows without a spring and the ring of colour fades in; the words are already in place.

Pitfalls

  • A spectrum made of seven bands shows steps even when blurred: it needs many thin bands (BANDS), each with its colour interpolated between the stops, and a still grain on top so the gradients do not band.
  • The prism must be drawn after the light and on the big canvas: on the small blurred one it would lose its edges and look like a smudge.
  • The point the spectrum leaves from moves when the prism turns: it must be worked out from the edges every frame, or the fan comes away from the glass.
  • The headline must stay readable over the colours: a wide shadow in the colour of the night behind the letters, and the red and blue fringe kept thin, never more than a couple of pixels.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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