Live demo
Demo source
Overview
Use a dropzone where people add files: they drop files on it, click it to
open the file picker, or paste a file while it has focus. Every route emits
the same filesSelected event with the raw files. The dropzone keeps no list,
doesn't validate and doesn't upload. For a list, checks and upload status,
use file upload.
Anatomy
The file upload anatomy shows the dropzone and its helper text above the file list in the upload composition.
Parts
- Illustration: a stack of cards with an upload icon at the default
mdsize, or a small icon atsm. Theiconslot replaces it. - Instruction: "Drag and drop or choose a file" by default.
instructionchanges it, and{browse}marks where the browse link (browseLabel) goes. - Helper text (optional): constraints such as file types or size.
States and themes
Default shows the instruction and helper text. Drag-over replaces the
instruction with dropInstruction; keyboard focus adds a focus ring.
Disabled blocks click, drop and paste. In multiple mode, file upload also
disables its composed dropzone when accepted (non-invalid) entries reach
the count limit. Both sizes support Spark
and Ocean in light and dark mode.
Accessibility
A native file input supplies keyboard access; picking files is always an alternative to dragging. The instruction labels the input, and helper text is associated with it. Keep the browse action and meaningful constraints when providing custom content.
Usage
- Say which files are welcome in the helper text.
acceptonly filters the file picker; dropped and pasted files arrive unfiltered, so check them yourself. - Without
multiple, only the first file is kept. localetranslates the built-in texts into English, French, Dutch or German.disabledblocks every route;disablePasteturns off pasting only.