A form control that lets the user select one or more files, or a folder.
- Slots
-
prefix— Renders content before the input. -
suffix— Renders content after the input. -
helper-text— Renders content below the input. -
file-selector-text— Renders content for the browse button. -
file-missing-text— Renders content when no file is chosen. -
value-missing— Renders content when the required validation fails. -
custom-error— Renders content when a custom message is set with `setCustomValidity()`. -
invalid— Renders content when the component is in invalid state (validity.valid = false).
- CSS Parts
-
container— The main wrapper that holds all main input elements. -
input— The native input element. -
label— The native label element. -
file-names— The file names wrapper. -
file-selector-button— The browse button wrapper. -
prefix— The prefix wrapper. -
suffix— The suffix wrapper. -
helper-text— The helper text wrapper. -
prefixed— Added to the container and the input when an element that is not hidden is in the prefix slot. -
suffixed— Added to the container and the input when an element that is not hidden is in the suffix slot. -
filled— Added to the container and the input when the control has a value. -
labelled— Added to the container in the material theme when the control has a label. -
start— The wrapper of the prefix in the material theme. -
notch— The wrapper of the label in the material theme. -
filler— The outline segment between the notch and the end in the material theme. -
end— The wrapper of the suffix in the material theme. -
file-parts— The wrapper of the browse button and the file names.
Properties
Section titled "Properties"accept
Section titled "accept"The file types the control accepts, as a comma-separated list.
accept: string autofocus
Section titled "autofocus"Whether the control receives focus automatically.
autofocus: boolean directory
Section titled "directory"Whether the user selects a folder instead of files. The selection then holds
every file in the folder and its subfolders, and the webkitRelativePath of
each file gives its path from the folder.
directory: boolean multiple
Section titled "multiple"Whether the control allows the user to select more than one file.
multiple: boolean outlined
Section titled "outlined"Whether the control has an outlined appearance.
outlined: boolean value
Section titled "value"The value of the control: the name of the first selected file, as the native file input gives it. As for the native file input, only an empty string can be set. It clears the selection.
value: string Accessors
Section titled "Accessors"files
Section titled "files"The list of selected files.
get files(): FileList
Returns FileList
Methods
Section titled "Methods"Removes focus from the control.
blur(): void Returns void
focus
Section titled "focus"Sets focus on the control.
focus(options: FocusOptions): void Parameters
- options:
FocusOptions
Returns void
select
Section titled "select"Selects all the text inside the input.
select(): void Returns void
Events
Section titled "Events"onCancel
Section titled "onCancel"Emitted when the control's file picker dialog is canceled.
onCancel(args: CustomEvent<FileList>): void Parameters
- args:
CustomEvent<FileList>
Returns void
onChange
Section titled "onChange"Emitted when the selection of the control changes.
onChange(args: CustomEvent<FileList>): void Parameters
- args:
CustomEvent<FileList>