FileUpload

A file picker with a drag-and-drop zone. The browse button is the keyboard and screen reader path; dropping is a shortcut for the pointer. Files are checked against accept, size and count before they are kept.

StableSource

Drag and drop files here

PNG, JPG or PDF, up to 2 MB each. Three files at most.

Import

import { FileUpload, type FileRejection } from "@meridui/react";

Examples

Single file

Without multiple, a new file replaces the old one.

Drop an image

No file

Disabled

Drag and drop files here

Uploads are paused.

Uploading

FileUpload only selects files. Send them from onValueChange (or on form submit — with name, the kept files are mirrored onto the real <input type="file">) and show progress with Progress.

API reference

Renders a div; other div attributes and the ref go on it.

PropTypeDefaultDescription
value / defaultValueFile[]–Controlled or initial files.
onValueChange(files: File[]) => void–Called with every kept file after an add or remove.
onReject(rejections: FileRejection[]) => void–Files that failed a check, with reasons: file-invalid-type, file-too-large, file-too-small, too-many-files.
acceptstring–As on <input type="file">: "image/*,.pdf". Also checked on drop.
multiplebooleanfalseKeep more than one file.
maxSize / minSizenumber–Size limits in bytes.
maxFilesnumber–Most files kept when multiple.
labelReactNode"Drag and drop files here"Main line in the dropzone.
buttonLabelReactNode"Browse files"Text of the browse button.
descriptionReactNode–Hint under the label; describes the button.
showFileListbooleantrueRender the file list with remove buttons.
getRemoveLabel(file: File) => stringRemove {name}Accessible name of a remove button.
getStatusText(count: number) => string"N file(s) selected"Announced when the selection changes.
localestring–Locale for file sizes (Intl units).
iconReactNode–Icon above the label.
invalid / disabled / requiredboolean–States; inside a Field they come from it.
namestring–Name of the file input for native form submit.

Styling

ClassElement
.mrd-file-uploadRoot (data-dragging, data-invalid, data-disabled)
.mrd-file-upload__dropzoneDashed drop area
.mrd-file-upload__icon, __label, __description, __buttonDropzone content
.mrd-file-upload__list, __item, __name, __size, __removeFile list

Accessibility

Drag and drop has no keyboard equivalent, so the dropzone is not focusable; the browse button inside it is. It is described by description and, inside a Field, named by the visible button text followed by the field label. Adding or removing files updates a visually hidden role="status" region ("2 files selected"). Removing a file returns focus to the browse button.

KeyAction
TabBrowse button, then each remove button.
EnterSpaceOn the browse button: open the file picker. On a remove button: remove that file.
  • Field — label, hint and error around a control.
  • Progress — upload progress.