FileUpload

React file upload with drag and drop, accept and size validation, per-file status and progress, and a compact button variant. Fully controlled, RTL ready.

FileUpload is fully controlled: you own the files array, run the upload yourself, and report each file's status. Validation uses accept, maxSize, and maxFiles.

When to use

Use FileUpload for attachments such as ID scans, contracts, or supporting documents. Set accept, maxSize, and maxFiles to match the service rules, and report each file's status as your upload proceeds.

Use the button variant inside dense forms and the drop zone when files are the main task. Keep the rules visible in the helper text.

Examples

Drag-and-drop zone

Single file (button variant)

Validation & rejections

Props

Props declared by FileUpload. Native attributes of the underlying element pass through.

PropTypeDefaultDescription
variant"button" | "dropzone"
filesrequiredUploadFile[]Controlled list of files to render. The consumer is the source of truth.
onFilesAddedrequired(accepted: File[]) => voidCalled with the files that passed validation. The consumer wraps each in an {@link UploadFile} (assigning an id) and starts the upload.
onFilesRejected(rejections: FileRejection[]) => voidCalled with files that failed validation. Never enter files.
onRemove(id: string) => voidPer-row remove handler. Omit to hide the remove button.
acceptstringNative accept string (e.g. 'image/*,.pdf'). Also drives validation.
maxSizenumberMaximum size per file, in bytes.
maxFilesnumberMaximum total files (existing + incoming). When multiple is false this is forced to 1.
multiplebooleanAllow selecting/dropping more than one file. Defaults to true.
disabledbooleanDisables the drop zone / button and the picker.
requiredbooleanMarks the field required: renders the asterisk and sets the input's required attribute.
labelreact.ReactNodeVisible field label, auto-associated to the input.
titlereact.ReactNode
descriptionreact.ReactNode
buttonLabelreact.ReactNode
errorMessagereact.ReactNodeMessage shown below the field when error is true.
errorbooleanMarks the field invalid: sets aria-invalid and error styling.
removeLabelstringAccessible label for the per-row remove button. Defaults to 'Remove'.
idstring
classNamestring
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.

Accessibility

The drop zone is also a button, so keyboard users can open the file picker with Enter or Space. Rejections are announced through a role="alert" list with the reason for each file.

Each file row exposes its status and a labelled remove button. The field label, helper text, and error are wired like TextInput.