# dots

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.

An even grid of small dots, plus marks or squares, the same pattern a CSS radial-gradient background draws. Around the pointer a soft lens forms: marks grow and take the accent color, slide away from it, or light up with a halo, depending on the mode. When the pointer stops the lens settles on it, and when it leaves the grid eases back. Drift slides the whole grid slowly, and fade lets it dissolve toward the edges. The background color of the element, read when the effect starts, stays under the grid.

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

A dark changelog hero with a dot grid beside the heading; dots near the pointer grow and turn periwinkle.

```html title="index.html"
<section class="dt-hero">
  <div class="dt-copy">
    <p class="dt-kicker">Changelog, version 4.2</p>
    <h2>Preview links for every pull request</h2>
    <p>Each branch gets its own URL in about forty seconds, and review comments stay pinned to the exact pixel.</p>
  </div>
  <div class="dt-grid" aria-hidden="true" data-dio="dots" data-dio-color="#4a5366" data-dio-accent="#8fa2ff" data-dio-radius="120" data-dio-strength="0.85" data-dio-fade="0.45"></div>
</section>
```

## Usage

Put it on: an empty decorative element behind the content, such as an aria-hidden div filling a hero or the top of a card; a CSS dot pattern on it is the look without WebGL.

`start()` registers `dots`, so the attribute alone puts it on an element.

```html
<header class="hero"><div class="hero-dots" aria-hidden="true" data-dio="dots" data-dio-fade="0.6"></div><h1>Ship docs your team reads</h1></header>
```

In page transitions: Fades with the page transition.

## Params

| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `style` (rebuilds) | `data-dio-style` | `'dots' \| 'plus' \| 'squares'` | `'dots'` | dots draws round dots; plus draws thin plus marks, four times as wide as dot; squares draws small squares. |
| `mode` (rebuilds) | `data-dio-mode` | `'grow' \| 'push' \| 'glow'` | `'grow'` | grow enlarges and tints marks near the pointer; push moves them aside; glow tints them with a halo. |
| `gap` | `data-dio-gap` | `number` 8 to 64 px | `24` | Distance between mark centers in CSS pixels. |
| `dot` | `data-dio-dot` | `number` 1 to 8 px | `2` | Mark size in CSS pixels: a dot's diameter or a square's side; a plus is 4 times wider. |
| `color` | `data-dio-color` | `color` | `'#a3acb9'` | Color of the marks at rest, any CSS color. |
| `accent` | `data-dio-accent` | `color` | `'#5b6cff'` | Color marks take under the pointer, any CSS color. |
| `radius` | `data-dio-radius` | `number` 0 to 400 px | `140` | Reach of the pointer lens in CSS pixels; 0 turns the pointer off. |
| `strength` | `data-dio-strength` | `number` 0 to 1 | `0.6` | Strength of the lens: how much marks grow, move or glow; 0 turns it off. |
| `speed` | `data-dio-speed` | `number` 0 to 40 px/s | `0` | Speed at which the grid slides; 0 keeps it in place. At most low 0. |
| `fade` | `data-dio-fade` | `number` 0 to 1 | `0` | How far the grid fades out toward the edges, from none to the middle. |

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

### Variants

- `style`: `dots`, `plus`, `squares`
  - `dots` draws round dots.
  - `plus` draws thin plus marks, four times as wide as dot.
  - `squares` draws small squares.
- `mode`: `grow`, `push`, `glow`
  - `grow` enlarges and tints marks near the pointer.
  - `push` moves them aside.
  - `glow` tints them with a halo.

## Inputs and frames

Reads [`delta`](/docs/api/inputs#input-delta), [`height`](/docs/api/inputs#input-height), [`over`](/docs/api/inputs#input-over), [`pointer`](/docs/api/inputs#pointer), [`reducedMotion`](/docs/api/inputs#input-reducedMotion), [`size`](/docs/api/inputs#size), [`width`](/docs/api/inputs#input-width). Draws at a steady rate while it is on screen and stops when it leaves. Frames only while the pointer moves over the grid and for about a second while the lens settles; with speed, up to 30 frames a second while on screen. 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 grid: no slide and no lens.

Runs on every device. No lens on touch screens, so a finger never draws frames; the slide still runs and scrolling works as usual.

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

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

## Cost and quality

Loads 2.0 KB the first time a page uses it. GPU: One pass over the element with a little math per pixel; push draws the nine nearest marks per pixel. Memory: None beyond the shared plane.

- low: No slide: the grid moves only under the pointer.

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

## Recipes

### Behind a SaaS hero

Put the grid 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. A CSS dot pattern with the same gap and color is what visitors see before the engine draws and without WebGL. Raise `fade` so the grid dissolves before the edges of the hero.

```html
<header class="hero">
  <div
    class="hero-dots"
    aria-hidden="true"
    data-dio="dots"
    data-dio-fade="0.6"
    data-dio-color="#cbd2dc"
    data-dio-accent="#4f46e5"
  ></div>
  <h1>Ship docs your team reads</h1>
  <a class="cta" href="/signup">Start writing</a>
</header>
```

```css
.hero {
  position: relative;
  isolation: isolate;
  min-height: 80vh;
}
.hero-dots {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle, #cbd2dc 1px, transparent 1.5px) 0 0 / 24px 24px;
}
```

```ts title="src/main.ts"
import { start } from '@dioramajs/diorama'

export const app = start({ canvas: 'behind' })
```

Keep the hero itself without a background color, or it covers the canvas behind it. A background color on the grid element is fine: the effect draws it under the dots.

### Plus marks on a blueprint

The `plus` style with `push` suits engineering and architecture products: thin plus marks on a pale panel slide out of the pointer’s way and settle back when it leaves.

Thin blue plus marks on a pale blue panel, moving aside around the pointer.

```html title="index.html"
<div class="dt-blueprint" aria-hidden="true" data-dio="dots" data-dio-style="plus" data-dio-mode="push" data-dio-gap="32" data-dio-color="#9db4d6" data-dio-accent="#1f5fd1" data-dio-radius="130" data-dio-strength="0.9"></div>
```

### A drifting glow for a dark section

With `speed` the grid slides slowly even without a pointer, which keeps a pricing or sign-up section alive on phones. `glow` lights the squares under the pointer with a soft halo.

```html
<div
  class="signup-bg"
  aria-hidden="true"
  data-dio="dots"
  data-dio-style="squares"
  data-dio-mode="glow"
  data-dio-speed="8"
  data-dio-gap="18"
  data-dio-dot="3"
  data-dio-color="#2a3140"
  data-dio-accent="#ffb347"
  data-dio-fade="0.7"
></div>
```

## Notes

The docs canvas sits above the page, so the examples here keep text beside the grid instead of over it. Put text over a grid with `canvas: 'behind'`, as in the first recipe.

The grid starts at the element’s top left corner, like a CSS background pattern, so a `radial-gradient` with the same gap matches it dot for dot. The element’s background color is read once, when the effect starts.

`dots` draws a frame only while the pointer moves over it and for about a second while the lens settles. With `speed` above 0 it draws up to 30 frames a second while on screen. On the low quality tier drift is off.

`style` and `mode` rebuild the effect when they change. The rest change live.

## Related

- [blobs](/docs/effects/blobs.md): Soft blobs of brand color drifting behind a hero: merging like a lava lamp, as blurred orbs or as glossy glass drops.
- [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.
- [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.
- [beam](/docs/effects/beam.md): A light beam that runs around the rounded border of a feature card, an input field or a highlight box.
- [beat](/docs/effects/beat.md): A cover, logo, card or play button that pulses with the music of a page player: it scales, shakes and glows, or sends out rings, on the beat.
- [Reduced motion](/docs/guides/reduced-motion.md)
- [Performance and quality](/docs/guides/performance.md)
