File Upload
kai-file-upload
A click-or-drag dropzone that fires one event with the selected files — constrain it to a file type, limit to a single pick, or lock it entirely with a single attribute.
- Shadow DOM
- 1 event
- Click or drag-and-drop
- Filterable by file type
- Customisable label
Preview
Section titled “Preview”All four props are plain HTML attributes — nothing to set in JavaScript:
<kai-file-upload accept="image/*" label="Drop an image to upload"></kai-file-upload><script type="module"> import '@kitn.ai/ui/elements'; document.querySelector('kai-file-upload') .addEventListener('kai-files-added', (e) => console.log(e.detail.files));</script>accept— standardacceptattribute (e.g.image/*,.pdf,.docx). Omit to allow any file type.multiple— boolean, defaults totrue. Setmultiple="false"to restrict to a single file.kai-files-added— fires withdetail.filesas a nativeFile[]; pass straight toFormDataor your upload function.
Examples
Section titled “Examples”Default
Section titled “Default”Accepts any file type; click or drag to trigger kai-files-added.
Images Only
Section titled “Images Only”accept="image/*" and multiple={false} — useful for avatar or cover-photo uploads.
Custom Label
Section titled “Custom Label”Override the default copy with label when context makes it too generic.
Disabled
Section titled “Disabled”Lock the dropzone while an upload is in progress or the user lacks permissions.
| Property | Type | Default | Notes |
|---|---|---|---|
| multiple | boolean | true | Allow selecting multiple files (default true). |
| accept | string | — | `accept` attribute for the file picker (e.g. `image/*`). |
| disabled | boolean | false | Disable the dropzone — no clicking, no drag-and-drop. |
| label | string | 'Click or drop files to upload' | Default dropzone label (overridable via the default slot). |
Events
Section titled “Events”| Event | Detail | Notes |
|---|---|---|
| kai-files-added | | Files were picked or dropped. |
Composed from
Section titled “Composed from”This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.
FileUploadFileUploadTrigger