# FileDropzone (@limerdev/zest) Picks files: `` with `bind:files` (a `File[]`) takes files dropped on it or chosen by browsing (a click, or Enter or Space on its focused input). It turns away files that don't match `accept`, are larger than `maxSize` or exceed `maxFiles`, and says why; `onReject` hears it too. Chosen files are listed with a remove button, and with a bar for those in `progress` (a `Map` of file to 0–1). The app does the upload; with `name`, a form posts the chosen files. Inside a `Field` it takes its id, label, description, error and invalid and disabled state from the Field. - Category: Data input - Import: `import { FileDropzone } from '@limerdev/zest'` - Exports: `FileDropzone` - Use for: Attaching receipts, invoices or images to a record; importing a CSV. - Don't: A single small file in a dense form: use `Input` with `type="file"`. Uploading inside the component: upload from `bind:files` in the app, and show it with `progress`. ```svelte Receipts Images or PDFs, up to 10 MB each. ``` Props of `FileDropzone`: - `accept` (`string`, default `undefined`): The file types it takes, as for an input: `image/*`, `.pdf`, `application/pdf`. - `files` (`File[]`, default `[]`, bindable): The chosen files, in the order they were added. Bindable. - `label` (`string`, default `the Config's `strings.dropFiles`, else 'Drop files here, or click to browse'`): The text in the drop area. - `locale` (`string`, default `the Config's `defaultLocale`, else the browser's`): The locale for file sizes (1,5 MB in `sv-SE`). - `maxFiles` (`number`, default `undefined`): How many files it holds at most; more are turned away. - `maxSize` (`number`, default `undefined`): The largest file it takes, in bytes. - `multiple` (`boolean`, default `false`): Takes several files. Without it a new file replaces the chosen one. - `onReject` (`((rejections: FileRejection[]) => void)`, default `undefined`): Called with the files turned away when files are added. - `progress` (`Map`, default `undefined`): Each file's upload progress, from 0 to 1, for files the app is uploading. A file without an entry shows no bar. - `rejectionMessage` (`((rejection: FileRejection, maxSize: string) => string)`, default `the Config's `strings.fileRejected`, else English messages: "report.exe isn't a type this takes."`): The message for a turned-away file, given the rejection and the largest size, formatted. - `removeLabel` (`((name: string) => string)`, default `the Config's `strings.removeFile`, else (name) => `Remove ${name}`): The remove button's accessible name, given the file's name. Example: Basic In a Field: images or PDFs up to 10 MB. Drop files on it, or click or press Enter to browse. ```svelte Receipts Images or PDFs, up to 10 MB each, five at most. ``` Example: Upload The app uploads: here a timer stands in for the request, and a SvelteMap of progress draws a bar per file. ```svelte
``` Example: States One CSV at a time (a new one replaces it), with its own label text; and disabled in its Field. ```svelte
Import Contract Locked once the invoice is sent.
```