Live demo
Demo source
Overview
Use file upload when a form needs one or more files. It combines a
dropzone with a list of
file tiles, checks each file, and keeps the
list in files. It never sends anything: your application uploads each
accepted file and writes its state, progress and message back into
files.
Anatomy
A file upload with six callouts: 1 marks the dropzone, 2 its helper text, 3 a completed file tile, 4 an upload progress bar showing 46%, 5 a rejected file, and 6 the summary below the list.
- Dropzone accepts files from a picker, drag and drop, or paste.
- Helper text gives the constraints from
accept,maxFileSize(in MB) andmaxFiles, such as "up to 10 files". - File tile shows a file's name, size, state and available action.
Accepted files start
queueduntil your application updates them. - Progress bar shows the upload's
progresswhile its state isuploading. - Rejected file stays in the list as
invalidwith the reason, such as "File too large — max 1 MB". - Summary appears when something went wrong, for example "1 file couldn't be added".
Properties
| Design setting | Code | Mapping |
|---|---|---|
| Size | size | md or compact sm. |
| File list | files | Items contain id, name, byte size, type, state, progress and message. |
| Helper text | accept, maxFileSize, maxFiles, helperText | Generated from constraints unless overridden; the size limit is in MB. |
| Instruction / browse label | instruction, browseLabel | Keep {browse} where the picker link belongs. |
| Drop instruction | dropInstruction | Replaces the instruction during drag-over. |
| Tile state | Each item's state | queued, uploading, processing, complete, error, invalid. |
| Disabled / read-only | disabled, readonly | Disable actions, or display the list without the dropzone and actions. |
| Feedback summary | Generated | Reports rejected files and upload failures. |
| Form and input behavior | multiple, required, disablePaste | Multiple selection, completed-file requirement, and clipboard control. |
| Field content / language | label, description, locale | Field context and localized built-in text. |
A label and description can introduce the field through props or the label
and description slots.
Look and feel
File tile states
| State | Presentation and action |
|---|---|
| Queued | Waiting to start; remove action. |
| Uploading | Measured progress; cancel action. |
| Processing | Indeterminate progress while the server works; no action. |
| Complete | Confirmation icon; remove action. |
| Error | Failure message, retry and remove. |
| Invalid | Rejection reason and remove; retry is not offered. |
| Disabled | Existing actions remain visible but cannot be used. |
| Read-only | File information without actions. |
Disabled and read-only are component properties, not additional state
values. The file tile overview illustrates
the individual states.
Dropzone states
The zone has a resting appearance, drag-over instruction, keyboard focus ring
and disabled state. In multiple mode, reaching maxFiles with accepted
(non-invalid) entries disables further selection. Choose
sm for narrow or dense layouts; md is the default. Both sizes follow
Spark and Ocean in light and dark mode.
Behavior
- Files arrive through the picker, a drop or paste.
- Type and size validation produce
invalidentries with specific messages; otherwise-valid files beyond the count limit are not added. - Accepted entries become
queued.filesAddedcarries afilesarray of{ id, file }pairs for the application to upload. - The application writes progress and state back to
files, and explicitly setscompleteonly after server confirmation. Reaching 100% is not enough. - Cancel, remove and retry emit
fileCancelled,fileRemovedandfileRetried; the application handles the request lifecycle. List changes emit the complete updated array throughfilesChanged.
Without multiple, selecting another file replaces the current one.
required keeps the form invalid until at least one file is complete.
Authentication, storage and retry policy belong to the application.
Accessibility
The native file picker provides a keyboard alternative to drag and drop.
Tile actions are buttons named for their file, and a tile's message is
associated through aria-describedby. The summary uses a polite status
region to announce list-level failures.
Content
Name the violated constraint, such as “Maximum file size: 25 MB”, and explain
what users can change. Keep custom instructions short and retain {browse}.
Built-in text and size formatting use English, French, Dutch or German;
unsupported languages fall back to English.
Usage
Treat validation rejection as invalid, with a specific reason and Remove.
Use error and Retry for upload failures that another attempt could resolve.
Avoid vague messages or retry actions on permanently unacceptable files.
Tokens
Spacing is grouped under file-upload-{sm,md}-gap-y,
file-upload-file-list-{sm,md}-gap-y, and the file-upload-dropzone-*,
file-upload-file-tile-* and file-upload-feedback-message-* families for
padding, gaps and radii.
Related
The composition combines Dropzone,
File tile and
Progress bar. In Blazor, NvInputFile
provides IBrowserFile values for application-side uploads; see the
framework examples.