blobs
Soft blobs of brand color drifting behind a hero: merging like a lava lamp, as blurred orbs or as glossy glass drops.
Live now, 1,204 listening
Night Drift radio
Slow electronic music around the clock, picked by hand. No ads, no talking, just the next track.
Start listeningLive preview needs WebGPU or WebGL 2. A radio station card with soft violet, cyan, pink and gold blobs drifting and merging over dark navy, beside the station name.
This example failed to draw.
Usage
Put it on an empty decorative element behind the content, such as an aria-hidden div filling a hero; its CSS background is the look without WebGL. start() registers blobs, so the attribute alone puts it on an element. The tabs below are the example above, with the values you set.
To change its code, copy the source into your effects folder; the copy replaces the built-in.
npx @dioramajs/diorama add blobs<article class="bl-radio"> <div class="bl-lava" aria-hidden="true" data-dio="blobs"></div> <div class="bl-info"> <p class="bl-kicker">Live now, 1,204 listening</p> <h2>Night Drift radio</h2> <p>Slow electronic music around the clock, picked by hand. No ads, no talking, just the next track.</p> <a href="/listen">Start listening</a> </div></article>import { start } from '@dioramajs/diorama'
const app = start()app.attach('.bl-lava', 'blobs', { style: 'lava', count: 6, color1: '#6d5dfc', color2: '#22d3ee', color3: '#f472b6', color4: '#fbbf24', background: '#0b1026', scale: 1, softness: 0.3, warp: 0.3, speed: 0.15, attract: 0.2, scroll: 0.25, grain: 0.03, fps: 30,})import { start } from '@dioramajs/diorama'import blobs from '@dioramajs/backgrounds/blobs'
const app = start()app.attach('.bl-lava', blobs({ style: 'lava', count: 6, color1: '#6d5dfc', color2: '#22d3ee', color3: '#f472b6', color4: '#fbbf24', background: '#0b1026', scale: 1, softness: 0.3, warp: 0.3, speed: 0.15, attract: 0.2, scroll: 0.25, grain: 0.03, fps: 30,}))Page transitions
Fades with the page transition. How a flight flies.
Params
Every param is also an attribute, and both app.attach() and the handle take it by name.
| Param | Type | Default | Description |
|---|---|---|---|
stylerebuildsdata-dio-style | 'lava' | 'orbs' | 'glass' | 'lava' |
|
countdata-dio-count | number0 to 8 | 6 | How many blobs show, up to 8; a fraction fades the last one in; 0 leaves the background.At most low 4 by quality tier. |
color1data-dio-color1 | color | '#6d5dfc' | Color of the first and fifth blobs, any CSS color. |
color2data-dio-color2 | color | '#22d3ee' | Color of the second and sixth blobs. |
color3data-dio-color3 | color | '#f472b6' | Color of the third and seventh blobs. |
color4data-dio-color4 | color | '#fbbf24' | Color of the fourth and eighth blobs. |
backgrounddata-dio-background | color | '#0b1026' | Color between the blobs. |
scaledata-dio-scale | number0.3 to 2.5 | 1 | Size of the blobs. |
softnessdata-dio-softness | number0 to 1 | 0.3 | How soft the edges are: 0 crisp shapes, 1 a wide blur; with orbs, the blur of each disc. |
warpdata-dio-warp | number0 to 1 | 0.3 | How much noise wobbles the edges; 0 keeps them round. |
speeddata-dio-speed | number0 to 1 | 0.15 | How fast the blobs travel; 0 holds them in place. |
attractdata-dio-attract | number0 to 1 | 0.2 | How far the blobs lean toward the pointer while it is over the element; 0 ignores it. |
scrolldata-dio-scroll | number0 to 1 | 0.25 | How far the blobs move along their paths while the element crosses the viewport. |
graindata-dio-grain | number0 to 0.2 | 0.03 | Strength of the film grain, one CSS pixel per grain; 0 leaves only the dithering. |
fpsdata-dio-fps | number0 to 60 | 30 | Most frames a second the drift draws; 0 holds it still.At most low 15, medium 24 by quality tier. |
seedrebuildsdata-dio-seed | number1 to 100 | 1 | Paths, sizes and rhythms of the blobs. |
Params marked rebuilds re-run the effect's setup when they change, so set them before the element shows.
Inputs and frames
It reads delta, hover, pointer, progress, reducedMotion and size
. Draws at a steady rate while it is on screen and stops when it leaves. Up to fps frames a second while on screen, none off screen or at fps 0; pointer and scroll draw at full rate. How a frame is decided.
Reduced motion and touch
With reduced motion it shows a still frame: motion inputs are zero and time stands still. A still frame: the blobs and the grain stop, and neither the pointer nor scroll moves them.
Runs on every device. The blobs lean toward a finger while it is on the screen; scrolling works as usual.
To change what reduced motion does, patch it in start().
import { start } from '@dioramajs/diorama'
start({ effects: { blobs: { reducedMotion: 'off' } } })Cost and quality
- Download
- 2.6 KB min+gzip the first time a page uses it
- GPU
- One pass over the element: one read of a small noise tile and a few operations per blob and pixel.
- Memory
- A 64 × 64 noise tile shared with gradient.
- Frames
- Draws while on screen
It runs from the low tier up. Each tier changes this: The quality plugin picks the tier for each device.
| Tier | What changes |
|---|---|
low | At most 15 frames a second and 4 blobs. |
medium | At most 24 frames a second. |
Recipes
Behind a SaaS hero
Put the blobs on an empty aria-hidden element that fills the hero and start the app with canvas: 'behind', so the heading and buttons sit over the canvas. The element’s CSS background is what visitors see before the engine draws and without WebGL, so give it the same background color.
<header class="hero"> <div class="hero-bg" aria-hidden="true" data-dio="blobs" data-dio-color1="#4f46e5" data-dio-color2="#06b6d4" data-dio-color3="#ec4899" data-dio-color4="#f59e0b" data-dio-background="#0b1026" ></div> <h1>Deploys you never think about</h1> <a class="cta" href="/signup">Start for free</a></header>.hero { position: relative; isolation: isolate; min-height: 80vh; color: #fff;}.hero-bg { position: absolute; inset: 0; z-index: -1; background: #0b1026;}import { start } from '@dioramajs/diorama'
export const app = start({ canvas: 'behind' })Orbs behind frosted glass cards
orbs keeps the blobs apart as blurred discs, the look behind glass cards with backdrop-filter. On a light page use pale brand colors and a near-white background.
<section class="plans"> <div class="plans-bg" aria-hidden="true" data-dio="blobs" data-dio-style="orbs" data-dio-count="4" data-dio-softness="0.6" data-dio-background="#f5f3ff" data-dio-color1="#a78bfa" data-dio-color2="#67e8f9" data-dio-color3="#f9a8d4" data-dio-color4="#fde68a" ></div> <div class="card">Pro, $12 a month</div></section>.card { background: rgb(255 255 255 / 0.55); backdrop-filter: blur(16px);}Glass drops for a launch
glass shades the merged shapes as glossy drops with a highlight and a bright rim. It reads best on a dark background with three to five drops and no grain.
Live preview needs WebGPU or WebGL 2. Five glossy drops in brand colors drifting and merging over a near-black background.
This example failed to draw.
<div class="bl-glass" aria-hidden="true" data-dio="blobs" data-dio-style="glass" data-dio-count="5" data-dio-scale="1.2" data-dio-grain="0" data-dio-background="#0e0f1a" data-dio-seed="3"></div>Readable text
Text sits over the blobs, so pick colors with contrast in mind:
- On a dark
backgroundsuch as#0b1026, set the heading in white and keep the blobs saturated but not near white. Keepgrainat 0.05 or below under body text. - On a light
backgroundsuch as#f5f3ff, use pale blobs and dark text such as#1b1530;orbswithsoftnessaround 0.6 keeps hard edges away from the letters. - Lower
countorscalewhen a blob keeps drifting under the heading, or put the heading on a card.
Notes
The docs canvas sits above the page, so the examples here draw nothing over the blobs. Put text over them with canvas: 'behind', as in the first recipe.
Unlike gradient, which fills the whole box with one wash, blobs draws distinct shapes with the background between them. Colors mix in OKLab where two blobs merge, and every pixel is dithered.
It draws up to fps frames a second while it is on screen and none off screen; the pointer and scroll draw at full rate while they move the blobs. With attract at 0 the pointer draws nothing. On the low tier it draws at most 15 frames a second and 4 blobs.
style and seed rebuild the effect when they change. Count, colors, sizes and speeds change live.