File Buttons
Svelte ComponentAllows you to select files with a single click.
Import
Package
Source
Doc
Examples
Monitor your browser's console when adding files.
Getting Started
Uses input[type='file']
and allows for all native input features and accessibility. Including multiple
,
accept
, and required
.
<FileButton name="files">Upload File</FileButton>
Binding Method
Use a FileList
to bind the file data.
let files: FileList;
<FileButton ... bind:files />
Variant Style
Use the button
property to provide classes for the button, such as variant styles.
<FileButton ... button="variant-filled-primary">Upload</FileButton>
On Change Event
Use the on:change
event to monitor file selection or changes.
function onChangeHandler(e: Event): void {
console.log('file data:', e);
}
<FileButton ... on:change={onChangeHandler}>Upload</FileButton>