Innate UIv0.1.0
Inputs

FileUpload

A composable file picker and dropzone with type, size, and count constraints.

FileUploadView source

Example

The preview is interactive. The code below it is the docs demo source; demo-only layout classes can be omitted in application code.

Drop images hereUp to 3 images total
tsx
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

PropTypeDefault
valuerequired

Selected files.

JSX.ValueOrCell<ReadonlyArray<File>>
childrenrequired

`FileUpload.Dropzone` and `FileUpload.Trigger` children.

JSX.Children
accept

Native file picker accept string, such as `image/*,.pdf`.

JSX.ValueOrCell<string | undefined>
multiple

Whether new selections append multiple files.

JSX.ValueOrCell<boolean>false
maxFiles

Maximum number of selected files in multiple mode.

JSX.ValueOrCell<number | undefined>
maxSize

Maximum accepted file size in bytes.

JSX.ValueOrCell<number | undefined>
capture

Preferred camera used by supporting mobile browsers.

JSX.ValueOrCell<"user" | "environment" | undefined>
disabled

Whether file selection is disabled.

JSX.ValueOrCell<boolean>false
invalid

Whether the file upload is in an invalid state.

JSX.ValueOrCell<boolean>false
ariaDescribedBy

Ids of elements that describe the file upload control.

JSX.ValueOrCell<string | undefined>
onChange

Called with the complete next selected-file value.

(files: ReadonlyArray<File>) => void
onReject

Called with files rejected by type, size, or count constraints.

(rejections: ReadonlyArray<FileUploadRejection>) => void

FileUploadDropzoneProps

PropTypeDefault
childrenrequired

Dropzone content.

JSX.Children
onDragEnter

Drag-enter handler called before Innate updates drop-target state.

EventHandlerProp<HTMLDivElement, DragEvent>
onDragLeave

Drag-leave handler called before Innate updates drop-target state.

EventHandlerProp<HTMLDivElement, DragEvent>
onDragOver

Drag-over handler called before Innate accepts a file drop.

EventHandlerProp<HTMLDivElement, DragEvent>
onDrop

Drop handler called before Innate validates the dropped files.

EventHandlerProp<HTMLDivElement, DragEvent>

FileUploadTriggerProps

PropTypeDefault
children

Button label or content.

JSX.Children
onKeyDown

Key-down handler.

EventHandlerProp<HTMLButtonElement, KeyboardEvent>
onBlur

Blur handler.

EventHandlerProp<HTMLButtonElement, FocusEvent>
onClick

Click handler.

EventHandlerProp<HTMLButtonElement, MouseEvent>
onFocus

Focus handler.

EventHandlerProp<HTMLButtonElement, FocusEvent>
onPointerEnter

Pointer-enter handler.

EventHandlerProp<HTMLButtonElement, PointerEvent>
onPointerLeave

Pointer-leave handler.

EventHandlerProp<HTMLButtonElement, PointerEvent>
onPointerMove

Pointer-move handler.

EventHandlerProp<HTMLButtonElement, PointerEvent>
disabled

Whether the button is disabled.

JSX.ValueOrCell<boolean>false
variant

Visual treatment of the button.

JSX.ValueOrCell<ButtonVariant>"secondary"
size

Button size.

JSX.ValueOrCell<ButtonSize>"medium"
loading

Shows the loading state and disables interaction.

JSX.ValueOrCell<boolean>false
Inspect the typed source →