@objectifthunes/whiteboard
FORMS

FileDrop

Drag-and-drop upload zone that is also a real file input. Stages files and reports rejections; never uploads.


PREVIEW
Drop files here, or click to browse

PNG, JPG or PDF · 2 MB per file

Up to 4 files, 2 MB each.

Drop a logo, or click to browse

SVG or PNG

Replaces rather than appends.

SOURCE
import { FileDrop, formatFileSize } from '@objectifthunes/whiteboard'

<FileDrop
  files={files}
  onFilesChange={setFiles}
  multiple
  maxFiles={4}
  maxSize={2 * 1000 * 1000}
  accept="image/*,.pdf"
  hint="PNG, JPG or PDF · 2 MB per file"
/>

// then upload them yourself
await Promise.all(files.map(f => upload(f)))
NOTES

It stages files and reports them; it does not upload. Transfer belongs to the caller, which owns the endpoint, the auth and the progress. Pair it with ProgressBar per file when you wire that up.

Files rejected by accept, maxSize or maxFiles are listed in the zone rather than silently dropped. A file that vanishes with no explanation reads as a broken uploader, and that is the most common complaint about drop zones.

accept is enforced on drop as well as on the file dialog, handling both the image/* and .pdf forms. The browser only applies it to the dialog, so a dropped file would otherwise skip the check entirely.

The zone is a real file input underneath, so clicking, dropping, and tabbing to it and pressing Enter all work. Re-picking the same file fires change again, because the input value is reset after each selection.