Skip to content
animorio
IT
Back to the library

Bokeh background

BackgroundsGSAP, Canvas, CSS onlyMediumCompressed weight: Demo 6.1 KBGSAP 28 KBFreeDownload the zip

A page background for the opening of a made-up listening bar, on near black: behind the headline the city lights seen out of focus, soft discs on three planes that drift and breathe, with a brighter rim and a hint of the six-bladed aperture in the largest. On arrival the focus racks from fully blurred into place; where the pointer passes, the nearby discs shrink and sharpen on a spring. Minimal style, canvas 2D.

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>
<!--
  "Bokeh 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>Bokeh background</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/jetbrains-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the opening of an invented late-night listening bar, Ember Room, on near black: behind the words the city lights
       seen out of focus, soft discs on three planes of focus that drift and breathe. Where the pointer passes, the focus
       moves there: the discs nearby shrink, sharpen and brighten, the rest melt back into the blur -->
  <main class="stage" data-stage>
    <canvas class="lights" data-lights aria-hidden="true"></canvas>
    <span class="vignette" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="kicker" data-in>
        <svg class="kicker__iris" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1.6 13.54 4.8V11.2L8 14.4 2.46 11.2V4.8Z" /><circle cx="8" cy="8" r="2.2" /></svg>
        Ember Room
      </p>
      <h1 class="title" id="hero-title" data-in><span class="title__line">The city,</span><span class="title__line">out of focus.</span></h1>
      <p class="lede" data-in>A listening bar on the ninth floor. Vinyl, low light, the skyline gone soft.</p>
      <p class="meta" data-in><span>Open till 2 am</span><span class="meta__rule" aria-hidden="true"></span><span>Floor 9</span></p>
    </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.

19 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Bokeh 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 opening of Ember Room, a made-up listening bar on the ninth floor, on near black. In the middle the label with the small drawn aperture, the headline «The city, out of focus.» in Mona Sans, its second line wider and lighter through the width axis, a line of copy and the details: Open till 2 am, Floor 9. Behind it, the city lights out of focus: some forty soft discs on three planes, many and small far away, few and large up close, in a warm amber with a redder tone and a few paler lights. Each disc has a rim slightly brighter than its centre, like the real discs of a lens, and in the largest the six-sided shape of the aperture just shows. On arrival everything is blurred and the focus racks into place while the words rise out of the haze. The discs drift slowly, the near ones faster than the far ones, and they breathe. Where the pointer passes, the focus moves there: the nearby discs shrink, sharpen and brighten, their rim turning into a thin line, and when the pointer leaves they melt back; every disc has its own spring, so they reach focus with a hair too much. Behind the words the discs dim a little so the headline reads.

How it works

Three planes

The discs come from a repeatable random, always the same, on three planes: many and small far away, mid, few and large up close. Positions are fractions of the page and sizes fractions of the short side, so a resize does not move the scene.

A disc of light

Each disc is a radial gradient with a softer centre and a brighter ring near the edge, then the falloff: the more out of focus, the larger it is, the softer its edge and the fainter, because the same light spreads over more space. The discs add up, like real light.

The aperture

In the largest discs the outline moves from a circle to the hexagon of the aperture: the radius of every point is mixed with that of a hexagon, by an amount set by HEX, and only while the disc is out of focus.

The focus

Each disc has a wanted blur: its plane’s, minus a Gaussian bell around the pointer, plus the entrance’s. The shown blur chases it on a spring, so each disc reaches focus with a hair too much and settles; in focus the rim becomes a thin line.

Drift and headline

The discs drift slowly, the near ones faster than the far ones, and wrap to the other side; they breathe on a sine, each at its own pace. An ellipse around the headline lowers their light so the words read.

Values to change

NameFileDefaultWhat it changes
COUNTscript.js46How many discs of light in all, across the three planes.
BLURscript.js1How out of focus they are at rest.
FOCUS_SIZEscript.js170Radius of the area that comes into focus under the pointer, in pixels.
DRIFTscript.js1Speed of the discs’ drift.
HEXscript.js0.5How much the six-sided aperture shows in the large discs.
GLOWscript.js1Light of the discs.
AUTO_PILOTscript.js2.5After how many idle seconds the fake pointer passes.
--accentstyle.css#ffb35cThe warm colour of the discs.
--accent-deepstyle.css#f0784aThe second, redder tone.

Try them in the Playground

When to use it

Behind the opening headline of a bar, an evening restaurant, a city hotel, a music night, a photographer or an app that wants the feel of the evening seen from a window.

On phones

The same scene with adapted sizes: sizes follow the short side, the headline is sized on width and height together and a tap brings the focus where the finger lands, for a couple of seconds.

With reduced motion

The discs stay, still and already in place: no drift, no breathing, no moving focus; the words are already there.

Pitfalls

  • The blur is made by widening the disc and softening the gradient, not with the canvas blur filter: the filter on forty discs every frame stalls a phone.
  • A disc’s light must drop as it widens, otherwise focusing would dim instead of brighten.
  • Positions as fractions of the page and sizes as fractions of the short side: in pixels, the demo window changing height would move the whole scene.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, JetBrains Mono (font variabile) 5.3.0.

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

Testing

Tested on 2 December 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