SelectFileInputWidget
A file-picker input, with drop-zone and button-only forms.
Basic usage
The file set is an array driven by the value / defaultValue / onChange channels; when not multiple, only the first file is kept. The clear indicator in the info field is the only way to clear (click it or press Enter).
Multiple selection and type filtering
multiple enables multi-select; accept restricts types with MIME or image/* patterns — it is written to the accept attribute and filters both the picker results and dropped files (the picker is already restricted, so most filtering happens on the drop path; files without a type are let through).
Drop-zone form
showDropTarget turns the whole component into a drop zone: when empty the whole block opens the picker on click, dragged-in files get accepted/rejected feedback, and dropping selects them. In single-select mode with an image file, a thumbnail is shown — loaded only for images within thumbnailSizeLimit (MB, default 20), falling back to an attachment icon when oversized or undecodable.
Dragging relies on the browser's DataTransfer constructor (Safari 14.1+); when unavailable, dragging turns off automatically and the select button keeps working. Pass droppable={false} to switch dragging off explicitly.
Button-only form
buttonOnly renders just the select button, without the info field; use it when you display the file name yourself.
Controlled use and programmatic changes
Passing value enables controlled mode — the file set is fully caller-driven. The demo wires an external "Clear" button that resets the set to [].
A value passed at construction is silently dropped by the original (a construction-order defect) and can only be applied afterwards with an imperative setValue. Following the controlled convention, this implementation applies value / defaultValue directly and writes the set back to the inner <input type="file">, so native form submission keeps working.
Focus and keyboard
- The select button is the
Tabstop; the info field is out of the Tab order. The clear indicator is keyboard-reachable (focus it and press Enter to clear). - The info field is a read-only
type="search"input — typing in it never changes the file set; clearing always goes through the clear indicator. requiredandnameland on the inner file<input>and submit natively with FormLayout.
API
title lands on the file <input> and tabIndex on the select button; the component ref points to the root element (the button itself in the buttonOnly form).
See also
- The value-channel contract: Controlled and uncontrolled
- Replacing built-in messages with a language pack: Global configuration
- The form submission container: FormLayout