File Dropzone
Svelte ComponentAllow upload of files with drag and drop.
Import
Package
Source
Doc
Examples
PNG, JPG, and GIF allowed.
Getting Started
Uses input[type='file']
and allows for all native input features and accessibility. Including multiple
,
accept
, and required
.
<FileDropzone name="files" />
You can override the default message
, as well as optionally provide icon
and meta
slots.
<FileDropzone name="files">
<svelte:fragment slot="lead">(icon)</svelte:fragment>
<svelte:fragment slot="message">(message)</svelte:fragment>
<svelte:fragment slot="meta">(meta)</svelte:fragment>
</FileDropzone>
Binding Method
Use a FileList
to bind the file data.
let files: FileList;
<FileDropzone ... bind:files />
On Change Event
Use the on:change
event to monitor file selection or changes.
function onChangeHandler(e: Event): void {
console.log('file data:', e);
}
<FileDropzone ... on:change={onChangeHandler}>Upload</FileDropzone>