Dither Reveal

An image that resolves from dithered palette tones into the photo.

Dither Reveal on a journal index, one image revealed
Still frame

Installation

pnpm dlx shadcn@latest add @gradients-pro/dither-reveal

Needs a Pro account and the Pro registry setup.

Usage

import { DitherReveal } from "@/components/dither-reveal";

<DitherReveal src="/photo.jpg" alt="" className="aspect-[4/3]" />;

Props

PropTypeDefaultDescription
srcstringrequiredThe image. Images on another origin need CORS headers and crossOrigin.
altstringrequiredAlternative text, passed to the <img>. Use "" when a nearby heading already describes it.
trigger"hover" | "visible" | "manual""hover""hover" reveals on hover and focus within; "visible" reveals once when half of it scrolls into view; "manual" follows revealed.
revealedbooleanfalseWith trigger="manual", shows the photo when true.
palette"ultramarine" | "ember" | "mono" | string[]"ultramarine"A curated ramp, or your own 2 to 6 CSS colours from faint to hot (var(--x) included). Curated ramps switch between a light and a dark version with your theme.
basestringnear-black or paperColour of the darkest cells.
cellnumber4Size of one dither cell in CSS pixels.
durationnumber900Milliseconds for the dissolve.
scheme"light" | "dark"follows the pageForces a colour scheme. By default it reads a dark or light class (or data-theme) on <html>, then the system setting.
crossOrigin"anonymous" | "use-credentials"nonePassed to the <img>.
childrenReactNodenoneDrawn above the image, for captions and badges.
className, other div propsThe outer box. Give it a size, such as aspect-[4/3].