Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Dither Field, animated React component

A free React dither background: a field of dots that shimmers between two colours the way old screens faked shades. Move the pointer to light the dots under it, press to send out a ring, or let the ghost pointer run the demo. Drop a headline on top and it becomes a hero.

  • Free
  • Background Effects
  • Hover
  • Glow

Like Dither Field? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Dither Field stays free.

Set it up, copy the code

Choose values for the main props and the JSX on the right updates to match.

Colour of the lit dots, as a hex value.

Colour of the unlit dots, as a hex value.

Size of one dot in CSS pixels. Bigger looks chunkier and costs less.

How fast the field drifts.

Pointer lights up the dots under it and a press sends out a ring.

A ghost pointer wanders over the field until the visitor touches it. Never runs under reduced motion.

Your JSX

<DitherField
  foreground="#1d1d1f"
  background="#f5f5f7"
  cellSize={4}
  speed={1}
  interactive={true}
  autoplay={false}
/>

Props

PropTypeDefaultWhat it does
foreground"#1d1d1f"Colour of the lit dots, as a hex value.
background"#f5f5f7"Colour of the unlit dots, as a hex value.
cellSize4Size of one dot in CSS pixels. Bigger looks chunkier and costs less.
speed1How fast the field drifts.
interactivetruePointer lights up the dots under it and a press sends out a ring.
autoplayfalseA ghost pointer wanders over the field until the visitor touches it. Never runs under reduced motion.
children—Anything to place on top of the field, such as a headline.
className""Extra classes for the outer element. Give it a height.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry

    Run this once per project. It writes the Nexus UI entry into components.json for you:

    npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"

    Type it exactly as shown. {name} is filled in by the CLI with the component you ask for, so you never replace it.

  1. 3

    Add the component

    Run this from your project root. It adds the component, the helpers it imports and its npm packages.

    npx shadcn@latest add @nexus-labs/dither-field
  2. 4

    Check what was added

    With a project made as in the Quick Start (a src/ folder), these files land in it:

    components/
    dither-field/
    dither-field.tsx
    index.ts
  3. 5

    Copying by hand? Skip the registry

    Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that cn() exists. Install the packages:

    npm install framer-motion

    Then show the source and create each file at the path it gives:

  4. 6

    Use it in a page

    Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:

    // src/app/page.tsx
    import { DitherField } from "@/components/dither-field";
    
    export default function Page() {
      return (
        <main>
          <DitherField />
        </main>
      );
    }

Like Dither Field? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Dither Field stays free.

Dither Field questions

How do I install the dither field?

Run `npx shadcn@latest add @nexus-labs/dither-field`. It adds one component and needs no other package.

What is dithering?

A way to show shades with only two colours. Each dot is either on or off, decided by comparing a soft moving pattern with a fixed grid of thresholds, so the shade comes from how many dots are on in an area.

How do I change the colours and dot size?

Pass `foreground` and `background` as hex values and `cellSize` in pixels. A bigger `cellSize` looks chunkier and uses less processing.

Can I put text on top of it?

Yes. Pass children and they sit above the field. Add `pointer-events-none` to the text wrapper if you want the pointer and presses to reach the dots underneath.

Does it respect reduced motion and save battery?

With reduced motion on, it draws one still frame and does not animate. It also stops drawing when it is scrolled out of view or the tab is hidden.

Guides