File upload

Drag and drop, or browse. The zone is a real button rather than a div that listens for clicks, so it can be reached and opened from the keyboard.

Reach for it

Attaching files, with drag and drop, size limits and per-file errors.

Not for

A bare file input of your own, which loses the limits and the error copy.

Several files

The accepted types are checked on the dropped path as well as the chosen one, because a drop bypasses the file dialog's own filter. A refused file is reported back to you rather than explained on the spot, since what to say about it is copy.

Supporting documents

One file

A single-file zone replaces its file rather than adding to it, so there is never a list of two where the user expected one.

Signed mandate

API reference

FileUpload

PropTypeDefaultDescription
value*File[]-The files held right now. Controlled: the caller owns the list.
onFilesChange*(files: File[]) => void-
prompt*string-Text inside the drop zone, e.g. "Drop files or browse". Always passed in.
removeLabel*(file: File) => string-Names the remove control for one file, e.g. `(file) => \`Remove \${file.name}\``.
data-testidstring-Names the element for a test. Never rendered, never announced.
hintstring-A second line, e.g. "PDF or PNG, up to 5 MB".
acceptstring-A comma-separated `accept` list, e.g. "application/pdf,image/png".
maxSizeBytesnumber-
isMultipleboolean-
isDisabledboolean-
onRejected(rejections: FileRejection[]) => void-Files that did not pass `accept` or `maxSizeBytes`. Reported rather than rendered: what to say about a rejected file is copy, and the package ships none. Put the message in a Field error or a Banner.