# Noise field

A slow, folding noise texture drawn as a dither, in four styles, with a mask that clears space for the text on top.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. The dithercn agent skill, for building any dither on the engine, is at [/.well-known/agent-skills/dithercn/SKILL.md](/.well-known/agent-skills/dithercn/SKILL.md).

<ComponentPreview src="examples/noise-field-demo.tsx" size="full" align="stretch" controls="noiseFieldControls">
  <NoiseFieldDemo />
</ComponentPreview>

## Installation [#installation]

<InstallBlock name="noise-field" />

## Usage [#usage]

```tsx
import { NoiseField } from "@/components/dithercn/noise-field";

export function Section() {
  return (
    <section className="relative isolate min-h-[480px]">
      <NoiseField mask="center" className="absolute inset-0 -z-10" />
      <h2>Your headline</h2>
    </section>
  );
}
```

The field is fractal noise folded back on itself, so it flows like smoke rather than scrolling. `variant` changes what the noise draws:

* `smoke`, the default: soft folds that dither into smooth gradients.
* `ridges`: sharp creases, like veins or lightning.
* `contours`: topographic lines, spaced by `bands`.
* `marble`: warped stripes, also set by `bands`.

`warp`, `detail` and `scale` shape the noise itself. `contrast`, `coverage` and `intensity` decide how much of it turns to ink. `angle` and `flow` set where it drifts, and `mask` with `maskSize` clears room for your text.

## Examples [#examples]

### Cleared under a headline [#cleared-under-a-headline]

`mask="center"` fades the field to paper in the middle of the box. Use `"top"` or `"bottom"` when the text sits at one end, and `maskSize` to clear more or less.

<ComponentPreview src="examples/noise-field-masked.tsx" size="lg" align="stretch">
  <NoiseFieldMasked />
</ComponentPreview>

### Fine grain in a dashboard card [#fine-grain-in-a-dashboard-card]

A high `scale`, a low `intensity` and 2px cells turn it into a texture you notice only when it moves.

<ComponentPreview src="examples/noise-field-card.tsx">
  <NoiseFieldCard />
</ComponentPreview>

### Topographic lines [#topographic-lines]

`variant="contours"` draws the noise as height lines, a good fit for maps and region stats. A bottom `mask` keeps the numbers on clean paper, and a low `flow` lets the terrain shift slowly.

<ComponentPreview src="examples/noise-field-topography.tsx">
  <NoiseFieldTopography />
</ComponentPreview>

### Marble with a highlight [#marble-with-a-highlight]

`variant="marble"` with more `warp` bends the stripes into veins. `highlight` adds a third colour for the brightest peaks, here the foreground, so the stripes catch the light.

<ComponentPreview src="examples/noise-field-marble.tsx" size="lg" align="stretch">
  <NoiseFieldMarble />
</ComponentPreview>

## Props [#props]

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `DitherColor` | `"--dither-ink"` | The ink of the texture. |
| `highlight` | `DitherColor` | `u2013` | A third colour for the brightest peaks. Leave it out for two tones. |
| `background` | `DitherColor` | `"--dither-paper"` | The paper behind. |
| `variant` | `"smoke" \| "ridges" \| "contours" \| "marble"` | `"smoke"` | The shape of the texture: soft folds, sharp creases, topographic lines or warped stripes. |
| `scale` | `number` | `1.3` | Size of the features. Higher values give smaller, busier noise. |
| `warp` | `number` | `1.7` | How far the noise folds back on itself, from 0 (plain noise) to 4. |
| `detail` | `number` | `4` | Octaves of noise, from 1 (smooth blobs) to 6 (fine grain on top). |
| `contrast` | `number` | `1.2` | 1 is soft. 2 and up give hard-edged islands. |
| `coverage` | `number` | `0` | How much of the box is inked, from -0.5 (sparse) to 0.5 (dense). |
| `intensity` | `number` | `0.9` | Brightest tone the field reaches, from 0 to 1. |
| `bands` | `number` | `8` | Lines for "contours" and stripes for "marble", from 2 to 24. |
| `angle` | `number` | `90` | Direction it drifts in, in degrees. 0 is right, 90 is up. |
| `flow` | `number` | `1` | How fast it drifts along angle, from 0 to 4. |
| `invert` | `boolean` | `false` | Swaps paper and ink. |
| `mask` | `"none" \| "center" \| "top" \| "bottom" \| "edges"` | `"none"` | Fades the field out where your text sits. "edges" keeps only the middle. |
| `maskSize` | `number` | `0.5` | How much of the box the mask clears, from 0 to 1. |
| `palette` | `[DitherColor, DitherColor, ...DitherColor[]]` | `Built from the colour props` | Takes over the colours: paper first, brightest last. Palette names, CSS variable names or any CSS colour. |
| `matrix` | `"bayer2" \| "bayer4" \| "bayer8" \| "blue-noise"` | `"bayer8"` | The threshold pattern. See Dither engine. |
| `levels` | `number` | `All the matrix can draw` | Tones the field snaps to before dithering. Low values give hard steps. |
| `cell` | `number` | `--dither-cell` | Size of one dither cell in CSS pixels. |
| `speed` | `number` | `1` | How fast it moves. |
| `animate` | `boolean` | `true` | false draws one still frame. |
| `stillTime` | `number` | `0` | The moment drawn when motion is off or reduced, in seconds. |
| `className` | `string` | `u2013` | Size and position. The background fills this box. |

## Notes [#notes]

* It is decorative and hidden from assistive technology. Put real text on top of it, not inside it.
* With reduced motion turned on, it draws one still frame and stops.
* It pauses when scrolled out of view or when the tab is hidden, and releases its WebGL context when far offscreen. Without WebGL it shows a CSS approximation in the same colours.
* It costs one small draw per frame at 30 fps, at one pixel per dither cell. Each step of `detail` adds a layer of noise, so lower it on large, busy pages. See [Performance](/docs/engine/performance).