Forms Form-associated
FileUpload <pm-file-upload>
File upload: drag-and-drop zone, file picker and paste (Ctrl/⌘+V on the focused zone), with type/size/count checks, image previews and a removable file list.
States
Each state is one attribute.
DisabledRead-onlyRequiredErrorOverview
Show upload progress per file with setProgress(file, %) and setStatus(file, 'done' | 'error', message). capture opens the camera on phones. Form-associated: submits the chosen files under name.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
name | string | — | Form field name: the files are submitted under it (default "files"). |
label | string | — | Visible label (use hide-label to hide it visually). |
hint | string | — | Help text under the drop zone, linked to it for screen readers. |
error | string | — | Custom error message (e.g. a server-side rejection). Setting it marks the field invalid. |
accept | string | — | Allowed types, like the native attribute: ".pdf,image/*". |
multiple | boolean | false | Accept more than one file. |
max-sizeprop: maxSize | number | — | Maximum size per file, in bytes. |
max-filesprop: maxFiles | number | — | Most files accepted when multiple is set. |
disabled | boolean | false | Not interactive and not submitted. |
required | boolean | false | The form cannot be submitted until a file is chosen. |
capture | 'user' | 'environment' | — | Phones: open the camera directly (user front, environment back). |
hide-labelprop: hideLabel | boolean | false | Hide the label visually; it stays the accessible name. |
readonly | boolean | false | Focusable and submitted, but the user cannot change the value. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-change | onPmChange | Files added or removed. |
pm-reject | onPmReject | A file was refused: wrong type, too large, or more files than allowed. |
Slots
| Slot | Description |
|---|---|
(default) | Custom drop-zone text. |
Methods
setProgress(), setStatus(), addFiles(), removeFile(), checkValidity(), reportValidity(), validate()