# blobs

Soft blobs of brand color drifting behind a hero: merging like a lava lamp, as blurred orbs or as glossy glass drops.

Up to eight round blobs in four brand colors float slowly over a flat background on looping paths, each swelling and shrinking a little on its own rhythm. In the lava style they merge where they meet and pull apart again, with soft edges and colors that blend in OKLab where two blobs join. Orbs keeps them apart as blurred discs layered over each other, the look behind frosted glass cards. Glass shades the merged shapes as glossy drops with a highlight and a bright rim, the background showing through their middle. They lean toward the pointer and move along their paths as the page scrolls. Unlike gradient, which fills the whole box with one wash of color, blobs keeps distinct shapes with the background between them.

Module `backgrounds`, category Backgrounds. Import `@dioramajs/backgrounds/blobs`. [Source](https://github.com/MasterKurosava/diorama/blob/main/packages/backgrounds/src/blobs.ts)

A radio station card with soft violet, cyan, pink and gold blobs drifting and merging over dark navy, beside the station name.

```html title="index.html"
<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>
```

## 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.

```html
<header class="hero"><div class="hero-bg" aria-hidden="true" data-dio="blobs" data-dio-background="#0b1026"></div><h1>Ship on Friday</h1></header>
```

In page transitions: Fades with the page transition.

## Params

| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `style` (rebuilds) | `data-dio-style` | `'lava' \| 'orbs' \| 'glass'` | `'lava'` | lava merges the blobs like a lava lamp, for SaaS and startup heroes; orbs draws separate blurred discs, for frosted glass cards over them; glass shades the merged shapes as glossy drops, for product and app launches. |
| `count` | `data-dio-count` | `number` 0 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. |
| `color1` | `data-dio-color1` | `color` | `'#6d5dfc'` | Color of the first and fifth blobs, any CSS color. |
| `color2` | `data-dio-color2` | `color` | `'#22d3ee'` | Color of the second and sixth blobs. |
| `color3` | `data-dio-color3` | `color` | `'#f472b6'` | Color of the third and seventh blobs. |
| `color4` | `data-dio-color4` | `color` | `'#fbbf24'` | Color of the fourth and eighth blobs. |
| `background` | `data-dio-background` | `color` | `'#0b1026'` | Color between the blobs. |
| `scale` | `data-dio-scale` | `number` 0.3 to 2.5 | `1` | Size of the blobs. |
| `softness` | `data-dio-softness` | `number` 0 to 1 | `0.3` | How soft the edges are: 0 crisp shapes, 1 a wide blur; with orbs, the blur of each disc. |
| `warp` | `data-dio-warp` | `number` 0 to 1 | `0.3` | How much noise wobbles the edges; 0 keeps them round. |
| `speed` | `data-dio-speed` | `number` 0 to 1 | `0.15` | How fast the blobs travel; 0 holds them in place. |
| `attract` | `data-dio-attract` | `number` 0 to 1 | `0.2` | How far the blobs lean toward the pointer while it is over the element; 0 ignores it. |
| `scroll` | `data-dio-scroll` | `number` 0 to 1 | `0.25` | How far the blobs move along their paths while the element crosses the viewport. |
| `grain` | `data-dio-grain` | `number` 0 to 0.2 | `0.03` | Strength of the film grain, one CSS pixel per grain; 0 leaves only the dithering. |
| `fps` | `data-dio-fps` | `number` 0 to 60 | `30` | Most frames a second the drift draws; 0 holds it still. At most low 15, medium 24. |
| `seed` (rebuilds) | `data-dio-seed` | `number` 1 to 100 | `1` | Paths, sizes and rhythms of the blobs. |

Changing a param marked rebuilds re-runs the effect setup.

### Variants

- `style`: `lava`, `orbs`, `glass`
  - `lava` merges the blobs like a lava lamp, for SaaS and startup heroes.
  - `orbs` draws separate blurred discs, for frosted glass cards over them.
  - `glass` shades the merged shapes as glossy drops, for product and app launches.

## Inputs and frames

Reads [`delta`](/docs/api/inputs#input-delta), [`hover`](/docs/api/inputs#hover), [`pointer`](/docs/api/inputs#pointer), [`progress`](/docs/api/inputs#progress), [`reducedMotion`](/docs/api/inputs#input-reducedMotion), [`size`](/docs/api/inputs#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. See [how a frame is decided](/docs/concepts/frames).

## 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.

```ts
import { start } from '@dioramajs/diorama'

start({ effects: { blobs: { reducedMotion: 'off' } } })
```

## Cost and quality

Loads 2.6 KB 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.

- low: At most 15 frames a second and 4 blobs.
- medium: At most 24 frames a second.

See [the quality plugin](/docs/effects/quality).

## 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.

```html
<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>
```

```css
.hero {
  position: relative;
  isolation: isolate;
  min-height: 80vh;
  color: #fff;
}
.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #0b1026;
}
```

```ts title="src/main.ts"
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`.

```html
<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>
```

```css
.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.

Five glossy drops in brand colors drifting and merging over a near-black background.

```html title="index.html"
<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 `background` such as `#0b1026`, set the heading in white and keep the blobs saturated but not near white. Keep `grain` at 0.05 or below under body text.
- On a light `background` such as `#f5f3ff`, use pale blobs and dark text such as `#1b1530`; `orbs` with `softness` around 0.6 keeps hard edges away from the letters.
- Lower `count` or `scale` when 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.

## Related

- [clouds](/docs/effects/clouds.md): A sky of soft layered clouds for the time of day, daylight, a sunset or a moonlit night, drifting in the wind and parting on scroll.
- [dots](/docs/effects/dots.md): A dot grid behind a hero or in a card that answers the pointer: dots near it grow, move aside or glow, then settle back.
- [gradient](/docs/effects/gradient.md): A living background of four soft color blobs or of aurora curtains, mixed in OKLab, without banding, with a light film grain.
- [grid](/docs/effects/grid.md): A grid floor in perspective running toward the viewer under a glowing horizon: neon synthwave, a blueprint or plain thin lines.
- [stars](/docs/effects/stars.md): A night sky of twinkling stars in depth layers that lean with the pointer and the scroll, with shooting stars and a warp flight.
- [waves](/docs/effects/waves.md): Topographic contour lines or flowing wave lines across a hero or footer, slowly changing and shifted by scroll.
- [drops](/docs/effects/drops.md): Water drops on glass over a hero or the whole page: rain that beads and runs, or meltwater left by a thaw.
- [snow](/docs/effects/snow.md): Snow, cherry petals or autumn leaves drifting down over a section or the whole page, for a seasonal campaign.
- [Performance and quality](/docs/guides/performance.md)
- [Reduced motion](/docs/guides/reduced-motion.md)
