Backgrounds

Dither Shader

An animated background in the retro aesthetic of ordered dithering noise.

Bayer-matrix ordered dithering quantizes a flowing plasma field into coarse-grained color steps, recreating the dithered noise texture of retro displays. Everything is drawn on canvas 2D, with no WebGL dependency.

Bring this into your project

Run this command in your project folder. The CLI adds the source and dependencies; then follow the usage example below.

npx webberui@latest add dither-shader.en

New project or installation trouble? Start here →

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

3
4
1
1
Active edited usageDefault props
<DitherShader/>

The complete example includes the preview layout and data. Install the component first, then paste this file into your project.

Installation

npx webberui@latest add https://webberui.com/r/dither-shader.en.json

Or, once registries are configured in components.json, install it as @webberui/dither-shader.

Usage

import { DitherShader } from "@/components/ui/dither-shader";

<DitherShader interactive className="h-[320px] w-full rounded-xl">
  <div className="grid h-full place-items-center text-white">Retro</div>
</DitherShader>

Setting levels to 2 gives you the classic pure two-tone dither; raise pixelSize to make the pixels chunkier.

Props

PropTypeDefaultDescription
colorBackstring"#0b1220"Shadow color (the pattern's low points)
colorFrontstring"#38bdf8"Highlight color (the pattern's high points)
pixelSizenumber3On-screen size of each dither pixel (px) — larger is chunkier
levelsnumber4Number of quantized color steps; 2 is a pure two-tone dither
speednumber1Animation speed multiplier
scalenumber1Pattern frequency — higher makes the ripples denser
interactivebooleanfalseA bright ring surfaces near the pointer (mouse only)
classNamestring—Forwarded to the container, for setting size and layout

Accessibility

  • When the user has "reduce motion" enabled at the system level, only a single static frame is drawn and the animation loop never starts
  • The canvas is a purely decorative layer marked aria-hidden, so foreground content is announced as usual