FileUpload
A composable file picker and dropzone with type, size, and count constraints.
FileUploadView sourceExample
The preview is interactive. The code below it is the docs demo source; demo-only layout classes can be omitted in application code.
import { Cell, For } from "retend";
import { Button, FileUpload } from "innate-ui";
import classes from "../docs.module.css";
export function FileUploadDemo() {
const files = Cell.source<ReadonlyArray<File>>([]);
const removeFile = (file: File) => {
files.set(files.get().filter((item) => item !== file));
};
return (
<div class={classes.fileUploadDemo}>
<FileUpload
value={files}
accept="image/*"
multiple
maxFiles={3}
onChange={(next) => files.set(next)}
>
<FileUpload.Dropzone>
<strong>Drop images here</strong>
<span>Up to 3 images total</span>
<FileUpload.Trigger>Browse images</FileUpload.Trigger>
</FileUpload.Dropzone>
</FileUpload>
<ul class={classes.fileUploadFiles}>
{For(files, (file) => (
<li>
<span title={file.name}>{file.name}</span>
<Button
size="small"
variant="ghost"
title={`Remove ${file.name}`}
onClick={() => removeFile(file)}
>
Remove
</Button>
</li>
))}
</ul>
</div>
);
}API reference
This table is generated from Innate UI's exported TypeScript declarations and JSDoc. Native element attributes inherited by a prop type are not repeated here.
FileUploadProps
| Prop | Type | Default |
|---|---|---|
valuerequiredSelected files. | JSX.ValueOrCell<ReadonlyArray<File>> | — |
childrenrequired`FileUpload.Dropzone` and `FileUpload.Trigger` children. | JSX.Children | — |
acceptNative file picker accept string, such as `image/*,.pdf`. | JSX.ValueOrCell<string | undefined> | — |
multipleWhether new selections append multiple files. | JSX.ValueOrCell<boolean> | false |
maxFilesMaximum number of selected files in multiple mode. | JSX.ValueOrCell<number | undefined> | — |
maxSizeMaximum accepted file size in bytes. | JSX.ValueOrCell<number | undefined> | — |
capturePreferred camera used by supporting mobile browsers. | JSX.ValueOrCell<"user" | "environment" | undefined> | — |
disabledWhether file selection is disabled. | JSX.ValueOrCell<boolean> | false |
invalidWhether the file upload is in an invalid state. | JSX.ValueOrCell<boolean> | false |
ariaDescribedByIds of elements that describe the file upload control. | JSX.ValueOrCell<string | undefined> | — |
onChangeCalled with the complete next selected-file value. | (files: ReadonlyArray<File>) => void | — |
onRejectCalled with files rejected by type, size, or count constraints. | (rejections: ReadonlyArray<FileUploadRejection>) => void | — |
FileUploadDropzoneProps
| Prop | Type | Default |
|---|---|---|
childrenrequiredDropzone content. | JSX.Children | — |
onDragEnterDrag-enter handler called before Innate updates drop-target state. | EventHandlerProp<HTMLDivElement, DragEvent> | — |
onDragLeaveDrag-leave handler called before Innate updates drop-target state. | EventHandlerProp<HTMLDivElement, DragEvent> | — |
onDragOverDrag-over handler called before Innate accepts a file drop. | EventHandlerProp<HTMLDivElement, DragEvent> | — |
onDropDrop handler called before Innate validates the dropped files. | EventHandlerProp<HTMLDivElement, DragEvent> | — |
FileUploadTriggerProps
| Prop | Type | Default |
|---|---|---|
childrenButton label or content. | JSX.Children | — |
onKeyDownKey-down handler. | EventHandlerProp<HTMLButtonElement, KeyboardEvent> | — |
onBlurBlur handler. | EventHandlerProp<HTMLButtonElement, FocusEvent> | — |
onClickClick handler. | EventHandlerProp<HTMLButtonElement, MouseEvent> | — |
onFocusFocus handler. | EventHandlerProp<HTMLButtonElement, FocusEvent> | — |
onPointerEnterPointer-enter handler. | EventHandlerProp<HTMLButtonElement, PointerEvent> | — |
onPointerLeavePointer-leave handler. | EventHandlerProp<HTMLButtonElement, PointerEvent> | — |
onPointerMovePointer-move handler. | EventHandlerProp<HTMLButtonElement, PointerEvent> | — |
disabledWhether the button is disabled. | JSX.ValueOrCell<boolean> | false |
variantVisual treatment of the button. | JSX.ValueOrCell<ButtonVariant> | "secondary" |
sizeButton size. | JSX.ValueOrCell<ButtonSize> | "medium" |
loadingShows the loading state and disables interaction. | JSX.ValueOrCell<boolean> | false |