Jump to a page or a component.
Dashed drop well and an upload list; accept, size and count enforced before you see a File.
No install — ask an AI agent to copy this component from registry.json, then pnpm add react-dropzone.
import { FileUpload, FileUploadDropzone, FileUploadItem, formatFileSize } from "@/components/ui/file-upload";onFilesAdded hands you the accepted Files, you start the request, and you mirror its state into files — each entry's status, progress and secondsLeft are what the list draws.useDropzone. accept is its MIME-to-extensions map, checked on drop and pick alike and fed to the native picker; maxSize and maxFiles are its options too. Anything else — a validator, minSize, noPaste, getErrorMessage for localised errors — goes through dropzoneOptions.maxFiles is per drop, not a running total: a batch larger than it is rejected whole with too-many-files. Cap the total in onFilesAdded if you need one.FileRejections (file + errors[].code), reported through onFilesRejected and never rendered. Show them the way the surrounding form shows its errors.data-drag-reject). Extension and size failures are only knowable on drop, so a drag of a too-large file still highlights normally.onRemove and onRetry are plain callbacks with the entry. Whether remove means abort, delete-from-server or drop-from-state is yours to decide; omit either and its button does not render.hint line is built from accept and maxSize in English by default. Pass your own to translate it.${base}-dropzone, ${base}-dropzone-input and ${base}-item-<id> derive from it, and each row's buttons add -remove-button / -retry-button.The props worth knowing. Everything else passes straight through to the underlying element, including className, which is merged last so it always wins.
| Prop | Type | Default | Description |
|---|---|---|---|
| files | FileUploadEntry[] | [] | Rows to draw: { id, name, size, status, progress?, secondsLeft?, error? }. |
| accept | Accept | AcceptGroup[] | — | react-dropzone map of MIME type to extensions: { "text/csv": [".csv"] }. Omit for anything. |
| maxSize | number | — | Largest file allowed, in bytes. |
| maxFiles | number | — | Most files one drop or pick may contain. |
| multiple | boolean | true | Let the picker choose several at once. |
| onFilesAdded | (files: File[]) => void | — | Files that passed every check. Start uploading them. |
| onFilesRejected | (rejections: FileRejection[]) => void | — | Files that failed a check, each with react-dropzone's errors. |
| dropzoneOptions | DropzoneOptions | — | Anything else for useDropzone: validator, minSize, noPaste, getErrorMessage. |
| onRemove | (entry: FileUploadEntry) => void | — | The row's trash button. Omit to hide it. |
| onRetry | (entry: FileUploadEntry) => void | — | A failed row's retry button. Omit to hide it. |
| title | string | "Click or drag files to upload" | Dropzone headline. |
| hint | string | from accept + maxSize | Dropzone second line. |
| removeLabel / retryLabel / uploadedLabel / failedLabel | string | "Remove" / "Retry" / "Uploaded" / "Upload failed" | Row copy. Pass translated strings from the call site. |
| formatTimeLeft | (seconds: number) => string | "24 sec left" | Readout for an uploading row's remaining time. |