Zone de dépôt de fichiers : glisser-déposer avec mise en évidence (et refus visuel des types non autorisés), liste avec miniatures d’images, icônes, tailles et suppression, validation du type, de la taille et du nombre, et progression par fichier ; associé aux formulaires (FormData).
Accepted types, like <input type=file>: “image/*,.pdf,application/zip”.
multiple
boolean
Multiple files (otherwise a new file replaces the previous one).
max-size
string
Max size per file: “5 MB”, “500KB”, “1048576”.
max-files
number
Max number of files (with multiple).
label
string
Main text of the zone (default: “Drag and drop files or browse”).
hint
string
Hint text (generated default: types · size · count).
layout
list | grid
list
Detailed list or thumbnail grid.
required
boolean
Native validation (valueMissing).
disabled
boolean
Disables the zone.
locale
string
en-US
Size formatting (Intl: “2.4 MB”). The value auto follows the page language (nearest lang); without the attribute, en-US unless the app registered the page language with setStrings() (core/i18n.js).
Properties
Name
Type
Description
files
File[]
Kept files (read-only).
items
Array<{ id, file, status, progress, error }>
State of each file: idle | uploading | done | error.
strings
Partial<Record<string, string | { one, other }>>
Overrides for the default text (en-US): dropFiles and dropFile (drop zone title, {browse} marks the link-styled word), browse, addFiles and addFile (fallback accessible name), images, videos and audio (accepted types in the hint), hintMaxSize ({size}), hintMaxFiles ({n}, { one, other }), selectedFiles (file list label), uploading (progress bar label, {name}), remove (remove button, {name}), uploaded, error, uploadFailed (default setError() message), errorType ({name}), errorSize ({name}, {size}), errorCount ({n}, { one, other }), announceAdded ({n}, { one, other }), announceRemoved, announceUploaded ({name}), announceError ({name}, {message}), valueMissing and valueMissingMultiple (required messages). App-wide translations: setStrings() from core/i18n.js, under the key "file-upload". Can be set before the element is defined.
Methods
Name
Description
open()
Opens the native file picker.
addFiles(files)
Validates and adds files; returns the accepted ones.
removeFile(file | id)
Removes a file (and releases its preview).
clear()
Clears the list.
setProgress(file | id, pct)
Updates the progress bar (100 = uploaded).
setError(file | id, message)
Marks a file as failed.
checkValidity() / reportValidity()
Native validation.
Events
Name
Description
mv-add
detail: { files }, accepted files (hook point to start the upload).
Generated parts; data-dragging / data-drag-reject on the host while dragging.
CSS variables
Name
Par défaut
Description
--mv-file-upload-width
32rem
Max width.
--mv-file-upload-zone-height
10rem
Min height of the zone.
--mv-file-upload-radius
var(--mv-radius-xl)
Zone radius.
Accessibility
The zone is a focusable role=button (Enter/Space open the picker), named by the <label for> and described by the hint text. Validation errors go in a role=alert region; additions, removals and completed uploads are announced through a polite live region. Each file has a “Remove <name>” button (focus moves to the next one) and a role=progressbar bar while uploading.