File Drop
Forms · FileDrop
Dashed drop zone plus an upload list. Click, Enter or drop to add files.
onFiles(files)hands over the realFileobjects the person picked or dropped, afteracceptandmultiple; upload them yourself. Dropped files that do not matchacceptgo toonReject; say so with an inline Alert, not a toast.- Progress is yours to report: control
files({ id, name, size, progress, file }) and setprogressfrom your upload. Below 100 a row shows a progress bar and a cancel button, at 100 it reads "uploaded". WithonFilesand nofiles, rows show only the size.onRemovetells you a file was removed or its upload cancelled. - Without
onFilesthe list animates made-up progress, as a demo of the look (simulateProgressturns that on or off). - The zone turns mint while a file is held over it, so people know the drop will land.
- Say what is accepted in the hint (types, size).
Drop files here or browsePDF, PNG or JPG up to 10 MB · drag several at once
Receipt-April-Hetzner.pdf180 KB · uploaded
Team-offsite-photos.zip46% · 23 MB
Props
FileDrop
| Prop | Type | Notes |
|---|---|---|
files? | UploadFile[] | The listed files (controlled); set `progress` per file to show real upload progress. |
onChange? | (f: UploadFile[]) => void | The list changed: files added (with their `file`) or removed. |
onFiles? | (files: File[]) => void | boolean | File[] | The person picked or dropped files: the real `File` objects, after `accept` and `multiple`. Upload them yourself. To show progress, control `files` and set each `progress`; an uncontrolled list shows them with their size only. Return `false` to list none of them, or the files to list (for example after checking their size). |
onReject? | (files: File[]) => void | Dropped files that do not match `accept` (show an inline Alert). |
onRemove? | (f: UploadFile) => void | A listed file was removed or its upload cancelled. |
simulateProgress? | boolean | Animate made-up progress for added files, as a demo of the look. Default: on without `onFiles` (as before), off with it. |
title? | string | |
hint? | string | |
accept? | string | Accepted types, as for `<input type="file">` ("image/*,.pdf"); also checked on drop. |
multiple? | boolean | |
disabled? | boolean | No picking or dropping; the list stays visible. |
name? | string | Takes part in a surrounding form under this name: the listed files are submitted with it. |
className? | string | Extra class on the root element. |
style? | CSSProperties | Inline style on the root element. |