Skip to documentation content

Dither Wave

A sea of color whose edge breaks into dots on a slow tide.

Figma
dither-wave-demo

Overview

Dither Wave fills the top of a section with color and lets its lower edge break into a grid of dots. The edge rises and falls like a slow tide, with a paler line of foam moving a little behind it.

It is drawn with SVG filters instead of a canvas, so it needs no WebGL and appears with the first paint of a server-rendered page. The wave stretches to its container while the dots keep their size. The area below the wave uses your page background, so it blends into the section that follows in light and dark themes.

Use it as a hero with the heading over the solid part of the wave, or as the top of a launch page.

Installation

npm install honestui

Usage

import { DitherWave } from "honestui/shaders"

<DitherWave className="min-h-[600px]">
  <div className="px-8 pt-26 text-center text-white">
    <h1 className="text-4xl leading-[1.06] font-medium tracking-[-0.04em] sm:text-[52px]">
      Ship on calm water.
    </h1>
    <p className="mx-auto mt-4 max-w-95 text-[15px] leading-normal">
      Plan, review, and release from one place.
    </p>
  </div>
</DitherWave>

Colors

color is the sea; its darker and paler tones are mixed from it. backgroundColor is the area below. Both accept any CSS color, including custom properties.

<DitherWave color="var(--primary)" backgroundColor="var(--card)" className="h-96" />

Accessibility

Dither Wave is decorative and its drawing is hidden from assistive technology. Keep text and actions in normal HTML, in roughly the upper third where the color is solid, and check their contrast against your color.

The tide stops when the user prefers reduced motion, and the wave stays in place.

API Reference

PropTypeDefaultDescription
colorstring"#2563ff"Color of the sea. Any CSS color.
backgroundColorstring"var(--background, #fff)"Color behind the wave, which the pale edge and the foam fade toward.
dotSizenumber5Distance between dots in CSS pixels, at least 2.
softnessnumber30How far the edge dissolves into dots, in CSS pixels. 0 is a hard edge.
foambooleantrueDraw the pale second wave below the first.
speednumber1Speed of the tide. 0 holds it still.
pausedbooleanfalseHolds the tide where it is.
classNamestring–Class for sizing and positioning the container.
childrenReactNode–Content rendered above the wave.