Inputs
FileDropzone
Attach imagesPNG or JPEG, up to 5 MB each
Accepted: none yet
Attach a single PDFOne PDF file
Attach filesUploads are paused
When to use
- You need an accessible upload area with mouse and keyboard support.
- You need the client-side limits
accept,maxSize,multipleand an explanation of rejections.
When not to use
- Do not show the upload state of already chosen files in the area — that is
UploadQueue. The area supplies files; the queue shows what happened to them. - Do not treat
FileDropzoneas an upload implementation: networking, progress, retries and server-side validation stay with the consumer. - For a single plain file input without a drop zone, a native
<input type="file">is enough.
Minimal example
<FileDropzone
accept="image/*"
maxSize={10 * 1024 * 1024}
onFiles={enqueueFiles}
onReject={showRejected}
hint="PNG or JPEG up to 10 MB"
/>Public API
onFilesis required and receives only the accepted files;onRejectreceives{ name, reason }[].acceptuses the syntax of theacceptattribute of a file input (image/*,.jpg,.png),multipleis true by default,maxSizeis in bytes.labelsets the accessible name of the DropZone;hintsets the text under the label,disableddisables the area,classNamechanges the look of the root element.- Folders, a wrong type, a file that is too large and extra files with
multiple={false}each get a rejection reason.
Accessibility and forms
- Do not remove the "Choose files" button: it lets keyboard users choose files.
- A rejection is shown in a live region
role="alert"; do not discard files silently. - See
src/components/inputs/FileDropzone.tsx,src/components/inputs/FileDropzone.stories.tsx,tests/file-dropzone.test.tsx.
TypeScript types
FileDropzoneProps
Prop
Type