# Waves

Layered swells under a glowing horizon, or thin lines like a sound wave, drawn as a dither.

> 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/waves-demo.tsx" size="full" align="stretch" controls="wavesControls">
  <WavesDemo />
</ComponentPreview>

## Installation [#installation]

<InstallBlock name="waves" />

## Usage [#usage]

```tsx
import { Waves } from "@/components/dithercn/waves";

export function Footer() {
  return (
    <footer className="relative isolate min-h-[320px]">
      <Waves className="absolute inset-0 -z-10" />
    </footer>
  );
}
```

Rows of swells roll towards you below the horizon. Distant rows are small and bright, near ones large and dark, and every crest has a one-cell highlight.

## Examples [#examples]

### Dusk [#dusk]

A lower `horizon`, eight `layers` and a warm palette give a sea at sunset. A smaller `amplitude` calms the water.

<ComponentPreview src="examples/waves-dusk.tsx" size="lg" align="stretch">
  <WavesDusk />
</ComponentPreview>

### Sound wave [#sound-wave]

`variant="lines"` draws thin lines that swell in the middle and taper at both ends. It suits audio players, voice input and anything that listens.

<ComponentPreview src="examples/waves-lines.tsx">
  <WavesLines />
</ComponentPreview>

## Props [#props]

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"ocean" \| "lines"` | `"ocean"` | Swells under a horizon, or thin lines like a sound wave. |
| `horizon` | `number` | `0.62` | Ocean only. Height of the horizon, from 0 (bottom) to 1 (top). |
| `layers` | `number` | `6` | How many waves, from 2 to 8. |
| `amplitude` | `number` | `1` | Height of the waves. 1 is calm, 2 is rough. |
| `palette` | `[DitherColor, DitherColor, ...DitherColor[]]` | `Paper, then tints of --dither-ink` | Colours from paper to ink: palette names such as "blue", CSS variable names, or any CSS colour. |
| `matrix` | `"bayer2" \| "bayer4" \| "bayer8" \| "blue-noise"` | `"bayer4"` | The threshold pattern. See Dither engine. |
| `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. |
| `className` | `string` | `–` | 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. See [Performance](/docs/engine/performance).