Dither Upload
A stippled border round a calm field with an upload mark, thickening into the accent when files are dragged over it. Drop files or browse for them (it's a real file input, so the keyboard works); each gets a row whose thumbnail prints as it uploads: an image develops in ink, shadows first, then shows its own colours once it's done, and any other file is a page that fills with ink, its type set on it. A thin dithered line shows progress. Files the accept list or size limit turns away stay on the list, marked, so it's clear why. You send the bytes: pass upload and report progress as it goes.
Needs: None. Canvas 2D. You bring the upload (fetch, XHR, a presigned URL).
Customize
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| upload | (file: File, report: (progress: number) => void) => Promise<void> | – | Sends a file, reporting progress 0 to 1. Leave unset to just collect files. |
| onFiles | (files: File[]) => void | – | Called with the files let in, each time some are added. |
| onRemove | (file: File) => void | – | Called when a file is taken off the list. |
| accept | string | "\"\"" | What's let in, as a file input's accept: “image/*,.pdf”. |
| multiple | boolean | true | Take several files, or one. |
| maxSize | number | – | The largest file let in, in bytes. |
| hint | string | – | The line under the call to action. |
| defaultFiles | File[] | – | Files already on the list when it first shows. |
| tone | string | – | The zone's ink with files over it, and the progress. The page's accent by default. |
| cell | number | 3 | Size of one dither cell in px. |
| className | string | – | Class on the uploader. |
| style | CSSProperties | – | Style on the uploader. |