API REFERENCE · FORM CONTROLS
<dj-file-input>
A form-associated file selector with a button that opens the system file picker and a focusable drop zone.
The component only selects files. It does not upload them or show previews. Selected files are listed with their size and a remove button.
npm install @dojo-ng/file-input
import "@dojo-ng/file-input";
Adding files
Files can arrive in four ways, and all of them go through the same checks:
- The file picker.
- A drop on the drop zone.
- A paste, such as a screenshot, while the drop zone has focus.
- The
addFiles(files)method, for files your app captured somewhere else, such as a paste in a message body or a drop on a whole pane.
Checks
acceptfilters the picker and drops, by extension, exact MIME type, ortype/*.- Without
multiple, a new file replaces the current one. max-size(bytes, per file) rejects a larger file and sets afileTooLargevalidity error, cleared on the next change.requiredwith no files reportsvalueMissing.
Value
- The form value is one
File, or, withmultiple, aFormDatawith one entry per file undername. files(read-only) is the current selection, andclear()empties it.dj-changefires with{ files }when files are added or removed.
Properties
| Property | Attribute | Type | Default |
|---|---|---|---|
accept |
accept |
string |
None |
multiple |
multiple |
boolean |
false |
required |
required reflected |
boolean |
false |
maxSize |
max-size |
number |
None |
label |
label |
string |
None |
name |
name reflected |
string |
None |
disabled |
disabled reflected |
boolean |
false |
Events
| Event | Description |
|---|---|
dj-change | { files } |
CSS parts
Style these with dj-file-input::part(name).
buttondropzonelistitemremovelabel
Methods
| Method | Description |
|---|---|
checkValidity(): boolean | |
reportValidity(): boolean | |
focus(options: FocusOptions) | |
clear() | Remove all selected files (no dj-change). |
addFiles(incoming: File[] | FileList) | Add files from any source, applying accept + multiple + max-size; appends, or replaces when not multiple. Emits dj-change. This is the single intake path — the picker, drop, and paste all route through it, and the app can call it to forward files captured elsewhere (e.g. a paste into the compose body or a drop on the whole pane). |