FileInput
A button that asks for files or photos, and the list of those chosen, each with a remove button.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | The button's text, such as Add photos. | |
files | { name: string; size?: number }[] | bindable([]) | What was chosen, by name and size in bytes. Bind it with bind:files={name}. |
icon | string | upload | The button's icon. |
onPick | () => void | Runs when the button is pressed: ask for files there, with the media-picker effect, and add what comes back to files. |
States
| State | Looks like |
|---|---|
empty | A dashed button. |
chosen | Each chosen file under the button, with its size and a remove button. |
Accessibility
| role | none; a button, then a button per file |
| name | The label prop names the button; each remove button says which file it removes. |
| focus | Tab reaches the button, then each remove button. |
| keyboard | Enter and Space press them. |
Theme tokens
color.border color.surface color.raised color.primary color.ink color.muted radius.full space.2 space.3 text.label text.body text.caption
Example
<FileInput label="Add photos" bind:files={photos} onPick={pick} />