Inputs
FileUpload
Drag and drop zone for selecting files, with type and size validation.
<script>
import { FileUpload } from "@codeatlasdev/ui";
let files = $state([]);
</script>
<FileUpload bind:files multiple accept="image/*" maxSize={10 * 1024 * 1024} />
The drop zone is a keyboard-operable control: Enter or Space opens the file picker. Files larger than maxSize are rejected with a per-file error message. In multiple mode new picks are appended to files, otherwise they replace it. The component never uploads: send files to your API yourself.
Native input attributes (name, capture, data-*…) are spread on the <input type="file">, and bind:ref gives you that input. To open the picker from a button elsewhere, keep the component instance with bind:this and call open() (a no-op while disabled). For apps that upload on pick and draw their own progress, set list={false}: onchange receives only the files just picked, nothing is kept in files, and the built-in list is not rendered.
Basic
Multiple files with a size limit and the selected count.
Reference #020 · Pick in the gallery
Code
Images only and disabled
Reference #021 · Pick in the gallery
Code
External trigger, no list
list={false} plus an Add files button that calls open().
Attachments
Reference #388 · Pick in the gallery
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
files | File[] | [] | Bindable list of selected files. |
accept | string | – | Accepted types, for example "image/*,.pdf". Shown as the hint when hint is not set. |
multiple | boolean | false | Allows selecting multiple files. |
maxSize | number | – | Maximum file size in bytes. Larger files are rejected with an error. |
label | string | 'Drop files here or click to browse' (localized) | Drop zone text and accessible name. |
hint | string | – | Helper text below the label. |
list | boolean | true | Shows the built-in file list. `false` makes a plain picker: `onchange` gets only the newly picked files and `files` is not kept. |
ref | HTMLInputElement | null | – | Bindable native file input. |
disabled | boolean | false | Disables the upload. |
class | string | – | Extra classes on the root. |
onchange | (files: File[]) => void | – | Called when the file list changes. |
children | Snippet | – | Custom content inside the drop zone. |