Dither upload
An image upload where the picture itself is the progress.
On this page
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
Usage
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
| Prop | Type | Notes |
|---|---|---|
file | { name, size, src, dimensions? } | null | |
progress | number | 0 to 1 |
rate | number | Bytes per second, for speed and time left |
onFiles | (files: File[]) => void | Only files that match accept and maxSize |
onRemove | () => void | The X: Cancel while uploading, Remove after |
error / onRetry | string / () => void | A failed upload keeps the picture where it got to |
onReject | (files: File[]) => void | Files the zone turned away |
accept / maxSize | string / number | Checked 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.