Skip to content
Sign in
EffectsError diffusion revealMenu

Error diffusion revealPro

The classic Mac look as a loading state: Atkinson or Floyd-Steinberg dithers that get finer, computed once in a worker and cached, then resolved into the photo.

ProAtkinson or Floyd-Steinberg frames at 6, 3 and 2 px, computed in a worker, then the photo.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/error-diffusion-reveal

Usage

tsx
import { ErrorDiffusionReveal } from "@/components/ui/chatcn/pro/error-diffusion-reveal"

<ErrorDiffusionReveal src={image.url} alt={image.prompt} kernel="atkinson" progress={job.progress} />

Error diffusion is serial and does not run in a shader, so each step is computed in a worker the moment the image loads, coarse first, and cached by size. If a step is not ready when it is due, the finest ready frame holds instead of a blank.

Examples

States

Waiting for the image, running at 40%, running with no numbers, held by revealed={false}, revealed, a missing file, a timer and right to left.

ProEvery state of the error diffusion reveal.

Props

PropTypeNotes
src, altstringalt is required: the accessible name, announced once the image is in
progressnumber | nullReal job progress, 0 to 1. null means running with no numbers. Leave it out for timer mode
revealedbooleanTimer mode: false holds the first frame, true plays once the image loads. Default true
durationnumberTimer length in ms. Default 1800
onRevealed() => voidOnce per image, when the plain image shows
onStatusChange(status: "loading" | "ready" | "revealing" | "revealed" | "error") => void
aspectRatio, width, heightSet the frame before the image loads, so nothing shifts
paperstringThe ground under the effect. Token or CSS color. Default var(--chatcn-bg)
announcementstring | falseWhat the live region says once revealed. Default Image ready: <alt>
errorText, retryLabelCopy for the error state and its reload button
kernel"atkinson" | "floyd-steinberg"Default atkinson
stepsnumber[]Cell sizes in CSS px, coarse to fine. Default [6, 3, 2]
inkstringDefault var(--chatcn-fg)
contrastnumberDefault 1.15
maxPixelsnumberDefault 1.5 MP

Keyboard

KeyAction
TabReaches the Reload image button in the error state. The reveal itself takes no focus

Accessibility

  • The effect layer is aria-hidden. The real <img> with your alt is always there, and the frame is aria-busy until the reveal ends.
  • A polite live region says Image ready: <alt> once, when the plain image shows. Progress ticks are never announced.
  • Under forced-colors: active the effect hides and the plain image shows with system colors.
  • A broken file shows what happened and a Reload image button that retries the download.

Motion

  • Each step is held for an equal share of 70% of the run; the last 30% crossfades the finest frame into the photo.
  • Under reduced motion one still frame holds while the job runs, then the image crossfades in over 200 ms. Nothing moves.
  • The timer only runs on screen in a visible tab; offscreen it waits where it was.