Skip to content
Sign upGet access
MicrointeractionsDither uploadMenu

Dither upload

An image upload where the picture itself is the progress.

Drag a photo over the zone and a dithered spotlight follows it; drop it and the picture resolves from one bit dither to full colour as the bytes land.

Dragging a file over the zone lights a dithered spotlight under the pointer. Drop it and the preview opens from where it landed as a coarse one bit dither, then arrives like a progressive scan: finer cells, a palette of its own colours, then the full photo, each pass sweeping down a scan line as the bytes land. The progress bar is an ordered dither too, its head dissolving into the track.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/dither-upload.json

Usage

tsx
import { DitherUpload } from "@/components/ui/chatcn/dither-upload"

<DitherUpload
  file={file}
  progress={progress}
  rate={bytesPerSecond}
  onFiles={([f]) => start(f, URL.createObjectURL(f))}
  onRemove={clear}
/>

The component draws; your upload code reports progress. Pass an object URL or a same origin address as file.src so the preview can be read.

Examples

Failed, and the empty zone

A dropped connection holds the picture where it got to, with Retry beside the reason; the empty zone checks type and size on drop, not only in the picker.

Props

PropTypeNotes
file{ name, size, src, dimensions? } | null
progressnumber0 to 1
ratenumberBytes per second, for speed and time left
onFiles(files: File[]) => voidOnly files that match accept and maxSize
onRemove() => voidThe X: Cancel while uploading, Remove after
error / onRetrystring / () => voidA failed upload keeps the picture where it got to
onReject(files: File[]) => voidFiles the zone turned away
accept / maxSizestring / numberChecked on drop too, not only in the picker
hint / disabled

Accessibility

  • The zone holds a real button that opens the file picker; the bar is a progress bar, and start, done, failed and turned away files are each announced once.
  • A file dropped while it is busy is swallowed, so the browser never leaves the page to open it.

Motion

  • The reveal opens in 350 ms; levels follow progress. Reduced motion: the bar holds still and the preview steps without the crawl.