Forms
FileUpload
Free19.2 KB gzippedFile picker with drag and drop, validation, and a file list. FileUpload.List is the standalone list for custom layouts.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Enter, Space · Full report
Import
import { FileUpload } from "@vjdesigns/vjdesigns-ui";
Importing only FileUpload adds about 19.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Dropzone
Drop files on the zone or browse. Accepted files are listed below with thumbnails and remove buttons.
Drop files here or browse
PNG, JPG or GIF, up to 5 MB each.
import { Field, FileUpload } from "@vjdesigns/vjdesigns-ui";
export function Dropzone() {
return (
<div style={{ width: "100%", maxWidth: "30rem" }}>
<Field label="Project images">
<FileUpload multiple accept="image/*" maxFiles={5} maxSize={5_000_000} hint="PNG, JPG or GIF, up to 5 MB each." />
</Field>
</div>
);
}
Compact button
variant="button" is a compact alternative for forms with little room.
import { Field, FileUpload } from "@vjdesigns/vjdesigns-ui";
export function CompactButton() {
return (
<div style={{ width: "100%", maxWidth: "30rem" }}>
<Field label="Résumé">
<FileUpload variant="button" accept=".pdf,.doc,.docx" hint="PDF or Word document." />
</Field>
</div>
);
}
Accessibility
The drop zone is a labeled button, so it works with the keyboard as well as drag and drop. showRejections lists each rejected file with its reason, and every file in the list has a remove button named after that file.
Drop files here or browse
PDF, images up to 1.9 MB each.
PDF or images, up to 2 MB each.
import { Field, FileUpload } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<div style={{ width: "100%", maxWidth: "30rem" }}>
<Field label="Receipts" hint="PDF or images, up to 2 MB each.">
<FileUpload multiple accept=".pdf,image/*" maxSize={2_000_000} showRejections />
</Field>
</div>
);
}
Translated
The prompt, the browse button, file sizes, rejection reasons and the remove buttons' names come from the locale (Brazilian Portuguese here).
Solte os arquivos aqui ou procure
Imagens. Até 4 arquivos.
import { Field, FileUpload, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ptBR from "@vjdesigns/vjdesigns-ui/locales/pt-BR";
export function Translated() {
return (
<LocaleProvider locale="pt-BR" messages={ptBR}>
<div style={{ width: "100%", maxWidth: "30rem" }}>
<Field label="Fotos do produto">
<FileUpload multiple accept="image/*" maxFiles={4} />
</Field>
</div>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Dropzone
أفلت الملفات هنا أو استعرض
PNG, JPG or GIF, up to 5 MB each.
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Dropzone is the "Dropzone" example above.
<LocaleProvider locale="ar" messages={ar}>
<Dropzone />
</LocaleProvider>
API reference
FileUpload
| Prop | Type | Default |
|---|---|---|
acceptFile types to accept, as in the native attribute: | string | — |
multipleAllow more than one file. Without it, a new file replaces the current one. | boolean | false |
maxFilesMaximum number of accepted files in total (with | number | — |
maxSizeMaximum size of each file, in bytes. | number | — |
minSizeMinimum size of each file, in bytes. | number | — |
validatorCustom rule. Return a human-readable error message to reject the file, or | (file: File) => string | null | — |
valueAccepted files (controlled). | File[] | — |
defaultValueInitially accepted files (uncontrolled). | File[] | — |
onValueChangeCalled with the full list of accepted files whenever it changes (added or removed). | (files: File[]) => void | — |
onRejectCalled with the files that failed validation in the latest selection or drop. | (rejections: FileRejection[]) => void | — |
onFileRemoveCalled when a file is removed with its remove button (e.g. to cancel its upload). | (file: File) => void | — |
disabledDisables the picker, drop target, and remove buttons. Inherits from a surrounding | boolean | — |
invalidInvalid state: danger border and | boolean | — |
nameForm field name. The native file input's | string | — |
requiredNative | boolean | — |
size
| "sm""md""lg" | "md" |
variantPresentation. | "dropzone""button" | "dropzone" |
childrenReplaces the prompt and hint inside the dropzone. A function receives | ReactNode | ((state: FileUploadRenderState) => ReactNode) | — |
promptPrompt text in the dropzone. | ReactNode | "Drop files here or browse" ("Drop a file here or browse" without `multiple`) |
hintHint under the prompt. Defaults to text built from | ReactNode | — |
browseLabelLabel of the button that opens the picker. | string | "Browse files" ("Upload files" for the `button` variant) |
showListShow the built-in file list. | boolean | true |
showRejectionsShow the latest rejections, with their reasons, under the picker. | boolean | true |
showThumbnailsShow image thumbnails in the list. | boolean | true |
getFileStatePer-file upload progress and status for the built-in list. | (file: File, index: number) => FileUploadFileState | undefined | — |
inputRefRef to the native | Ref<HTMLInputElement> | — |
buttonRefRef to the Browse button. | Ref<HTMLButtonElement> | — |
idid for the Browse button (the focusable control). Inside a | string | — |
Also accepts native <div> attributes, plus className, style and ref.
FileUpload.List
| Prop | Type | Default |
|---|---|---|
filesRequiredThe files to show. | File[] | — |
onRemoveCalled when a remove button is pressed. Omit to hide remove buttons. | (file: File, index: number) => void | — |
getFileStatePer-file upload progress and status. | (file: File, index: number) => FileUploadFileState | undefined | — |
showThumbnailsShow image thumbnails (object URLs, revoked on removal and unmount). | boolean | true |
disabledDisables the remove buttons. | boolean | false |
aria-labelAccessible name of the list. | string | "Selected files" |
removeLabelBuilds each remove button's accessible name. | (fileName: string) => string | (name) => `Remove ${name}` |
focusFallbackElement to focus after the last file is removed (for example the Browse button). Otherwise focus moves to the next item's remove button, or the previous one when the last item was removed. | () => HTMLElement | null | undefined | — |
sizeRow density. | "sm""md""lg" | "md" |
Also accepts native <ul> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
FileUpload targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| EnterSpace | On the browse button: opens the file chooser. Files can also be dropped on the zone. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Drop zone | group | aria-labelledby → label |
| Browse button | button | aria-describedby → accepted types and limits |
| File list remove buttons | button | aria-label ("Remove …") |
| Live region | status | Announces added, rejected and removed files |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |