# FileUpload

> File picker with a drop zone, validation, a file list and an optional upload queue from @salmonui/inputs/file-upload, on a native file input so files submit with the form.

Canonical: https://salmonui.dev/docs/inputs/file-upload

`FileUpload` is a file picker with an optional upload queue. It renders a real
`<input type="file">` (visually hidden; it carries the files), a drop zone
`<button>` that opens the picker and accepts drops, the file list and one
polite live region. The label, description and error come from the shared
[Field](https://salmonui.dev/docs/inputs/field) parts.

```tsx
import { FileUpload } from '@salmonui/inputs/file-upload';
import '@salmonui/inputs/file-upload/styles.css';

// Files submit with the form: no upload request.
<FileUpload name="attachments" label="Attachments" multiple accept=".pdf,image/*" maxSize={2_000_000} />
```

### Live demo: FileUpload basics

Live demo: https://salmonui.dev/demos/inputs/file-upload-basics

A FileUpload without a transport inside a Form; the picked files submit with FormData, with accept, size and count validation.

`Demo.tsx`:

```tsx
'use client';

import { useState } from 'react';
import { Button } from '@salmonui/buttons/button';
import { FileUpload } from '@salmonui/inputs/file-upload';
import { Form } from '@salmonui/inputs/form';

// No transport: the files stay in the native input and submit with the form.
export default function FileUploadBasicsDemo() {
  const [sent, setSent] = useState<string[]>([]);
  return (
    <Form
      onSubmit={(event) => {
        event.preventDefault();
        setSent([...new FormData(event.currentTarget).getAll('attachments')].map((v) => (typeof v === 'string' ? v : `${v.name} (${v.size} bytes)`)));
      }}
      style={{ display: 'grid', gap: 12, maxWidth: 360 }}
    >
      <FileUpload
        name="attachments"
        label="Attachments"
        description="PDF or images, up to 2 MB each, at most 3 files"
        multiple
        required
        accept=".pdf,image/*"
        maxSize={2 * 1024 * 1024}
        maxFiles={3}
      />
      <div style={{ display: 'flex', gap: 8 }}>
        <Button type="submit" tone="primary">
          Send
        </Button>
        <Button type="reset" variant="outline">
          Reset
        </Button>
      </div>
      <output>{sent.length ? `FormData: ${sent.join(', ')}` : 'Nothing sent yet'}</output>
    </Form>
  );
}
```

## Two modes

- **Without `upload`** the component is a styled native file input. Picked
  and dropped files are mirrored into the input's `files`, so `FormData`,
  `<form action={fn}>` and React 19 server actions receive them; removed and
  invalid files are taken out of the input. `required`
  is the native constraint: it is met by files in the input, not by
  preloaded entries.
- **With `upload`** every valid file goes through a transport queue:
`upload(file, { signal, onProgress })` returns a promise that
  resolves when the server accepted the file. Omit `name` when you upload
  with a transport, or the files are also submitted with the form.

```tsx
import { createXhrUploader } from '@salmonui/inputs/file-upload/xhr';

const upload = createXhrUploader({ url: '/api/files', fieldName: 'file', headers: { 'X-CSRF-Token': token } });

<FileUpload label="Photos" multiple accept="image/*" upload={upload} concurrency={2} />
```

### Live demo: FileUpload queue

Live demo: https://salmonui.dev/demos/inputs/file-upload-queue

An upload transport with progress, two uploads at a time, cancel, retry and a manual Upload button when autoUpload is off.

`Demo.tsx`:

```tsx
'use client';

import { useRef, useState } from 'react';
import { Checkbox } from '@salmonui/inputs/checkbox';
import { FileUpload, type FileUploadApi, type UploadTransport } from '@salmonui/inputs/file-upload';

// A simulated transport: progress over about two seconds, every third file fails.
let count = 0;
const simulated: UploadTransport = (file, { signal, onProgress }) =>
  new Promise((resolve, reject) => {
    const fail = ++count % 3 === 0;
    let loaded = 0;
    const timer = setInterval(() => {
      loaded = Math.min(file.size, loaded + Math.max(1, file.size / 20));
      onProgress(loaded, file.size);
      if (loaded < file.size) return;
      clearInterval(timer);
      if (fail) reject(new Error('Simulated server error'));
      else resolve({ id: `${file.name}-${Date.now()}` });
    }, 100);
    signal.addEventListener('abort', () => {
      clearInterval(timer);
      reject(signal.reason);
    });
  });

export default function FileUploadQueueDemo() {
  const api = useRef<FileUploadApi>(null);
  const [auto, setAuto] = useState(true);
  const [done, setDone] = useState('');
  return (
    <div style={{ display: 'grid', gap: 12, maxWidth: 400 }}>
      <Checkbox checked={auto} onCheckedChange={(checked) => setAuto(checked)}>
        Upload as soon as files are added
      </Checkbox>
      <FileUpload
        ref={api}
        label="Photos"
        multiple
        accept="image/*,.pdf"
        upload={simulated}
        autoUpload={auto}
        concurrency={2}
        defaultFiles={[{ name: 'team-offsite.jpg', size: 1_248_213, type: 'image/jpeg' }]}
        onUploadComplete={(files) => setDone(`${files.filter((f) => f.status === 'uploaded').length} of ${files.length} uploaded`)}
      />
      <output>{done || 'Add photos to start the queue'}</output>
    </div>
  );
}
```

## File states

Each entry (`FileEntry`: `id`, `name`, `size`, `type`, `file`, `path`,
`status`, `progress`, `error`, `reason`, `result`) moves through
`queued` → `uploading` → `uploaded` | `error` | `canceled`; files rejected by
validation are `invalid` with an `error` code:

| Error code | Cause |
| --- | --- |
| `type` | not matched by `accept` (extensions such as `.pdf`, `image/*`, exact MIME types) |
| `tooSmall` / `tooLarge` | below `minSize` / above `maxSize` bytes |
| `tooMany` | beyond `maxFiles` valid files |
| `upload` | the transport rejected (status `error`) |
| `remove` | the `remove` hook rejected; the file stays |

## Queue

- `autoUpload` (default `true`) starts valid files as soon as they are
  added; with `false` an Upload button and `api.upload(ids?)` start them.
- `concurrency` limits parallel uploads; `1` is sequential, the default is
  unlimited.
- Progress from `onProgress(loaded, total)` is applied at most once per
  animation frame and shown as a `<progress>` per file.
- `api.cancel(id)` and the per-file cancel button abort the transport's
  `AbortSignal`; `api.retry(id)` and the retry button re-run the
  transport for an `error` or `canceled` file.
- `onUploadComplete(files)` fires when the queue drains.

## Drop zone and folders

The drop zone button accepts drops; `dropTarget` (a ref) makes another
element the drop area. `dropEffect` (`'copy'`, `'move'`, `'link'`,
`'none'`; default `'copy'`) is set on `dataTransfer` while dragging, and
`'none'` refuses drops. The root carries `data-dragging` during a
drag; it is a DOM attribute, so dragging never re-renders React.
`directory` adds `webkitdirectory` to the input and walks dropped folders
recursively with `webkitGetAsEntry()`; each entry's `path` is
folder-relative. On touch devices the button opens the mobile
picker; `capture` passes through for camera capture.

## File list

`showFileList` (default `true`) shows the list. `renderFile(ctx)`
renders the content of each item with `{ file, status, progress, error,
statusText, sizeText, remove, retry, cancel }`. `renderTrigger({ open, text })`
replaces the drop zone content and `localeText` renames every string.
The order is the order of `files`: sort a controlled list to sort
the view (see below).

`files` / `defaultFiles` / `onFilesChange(files, { source, reason })` hold
the list. Without `files` the component keeps the
list itself (uncontrolled, starting from `defaultFiles`); with `files` you
own it and write back what `onFilesChange` reports. Preloaded entries need
only `name` and `size` and default to status `'uploaded'`; `source` is
`'pointer'` or `'api'` and `reason` is `'add'`, `'remove'`, `'clear'`,
`'status'`, `'progress'` or `'reset'`. A form `reset` aborts uploads and
restores `defaultFiles`.

`localeText` keys are the drop zone text (`browse`), the
toolbar buttons (`uploadAll`, `clearAll`), the per-file button names
(`removeFile`, `cancelFile`, `retryFile`), the live-region count
(`filesAdded`), one per status (`queued`, `uploading`, `uploaded`,
`error`, `canceled`) and one per error code (`type`, `tooSmall`,
`tooLarge`, `tooMany`, `upload`, `remove`); `{0}` is the file name, the
limit or the count.

### Live demo: FileUpload customization

Live demo: https://salmonui.dev/demos/inputs/file-upload-custom

Preloaded files, a custom file row from renderFile, a custom drop zone from renderTrigger, renamed status and error texts with localeText, folder picking, the drop effect and showFileList.

`Demo.tsx`:

```tsx
'use client';

import { useState } from 'react';
import { Button } from '@salmonui/buttons/button';
import { Checkbox } from '@salmonui/inputs/checkbox';
import { FileUpload, type FileRenderContext, type FileUploadLocaleText } from '@salmonui/inputs/file-upload';
import { Select } from '@salmonui/dropdowns/select';

type DropEffect = 'copy' | 'move' | 'link' | 'none';

const DROP_EFFECTS = [
  { value: 'copy', label: 'copy' },
  { value: 'move', label: 'move' },
  { value: 'link', label: 'link' },
  { value: 'none', label: 'none (refuse drops)' },
];

// Every status and error text renamed; `{0}` is the limit.
const TEXT: FileUploadLocaleText = {
  browse: 'Choose files or drop them here',
  clearAll: 'Remove all',
  removeFile: 'Delete {0}',
  uploaded: 'Saved',
  queued: 'Added',
  type: 'Only PDF files and images',
  tooLarge: 'Too big: the limit is {0}',
};

const PRELOADED = [
  { name: 'contract.pdf', size: 182_340, type: 'application/pdf' },
  { name: 'site-photo.jpg', size: 734_002, type: 'image/jpeg' },
];

// A custom row: name or folder path, size, status and a named Remove button.
function row({ file, status, statusText, sizeText, remove }: FileRenderContext) {
  return (
    <div style={{ display: 'flex', gap: 8, alignItems: 'center', inlineSize: '100%' }}>
      <span aria-hidden="true" style={{ fontSize: 11, fontWeight: 700, padding: '2px 4px', border: '1px solid currentColor', borderRadius: 'var(--salmon-radius-sm)' }}>
        {file.type.startsWith('image/') ? 'IMG' : file.name.toLowerCase().endsWith('.pdf') ? 'PDF' : 'FILE'}
      </span>
      <span style={{ flex: 1, minInlineSize: 0, overflowWrap: 'anywhere' }}>
        <strong>{file.path}</strong>
        <br />
        <small>
          {sizeText} · <span data-status={status} style={status === 'invalid' || status === 'error' ? { color: 'var(--salmon-color-danger-text)' } : undefined}>
            {statusText}
          </span>
        </small>
      </span>
      <Button type="button" variant="outline" onClick={remove} aria-label={`Delete ${file.name}`}>
        Delete
      </Button>
    </div>
  );
}

export default function FileUploadCustomDemo() {
  const [directory, setDirectory] = useState(false);
  const [dropEffect, setDropEffect] = useState<DropEffect>('copy');
  const [showFileList, setShowFileList] = useState(true);
  const [count, setCount] = useState(PRELOADED.length);
  return (
    <div style={{ display: 'grid', gap: 12, maxWidth: 440 }}>
      <div className="demo-toolbar">
        <Checkbox checked={directory} onCheckedChange={(checked) => setDirectory(checked)}>
          Pick folders
        </Checkbox>
        <Checkbox checked={showFileList} onCheckedChange={(checked) => setShowFileList(checked)}>
          Show the file list
        </Checkbox>
        <label>
          Drop effect
          <Select aria-label="Drop effect" data={DROP_EFFECTS} value={dropEffect} onValueChange={(value) => value != null && setDropEffect(value as DropEffect)} />
        </label>
      </div>
      <FileUpload
        label="Project files"
        description="PDF files and images up to 1 MB"
        multiple
        accept=".pdf,image/*"
        maxSize={1024 * 1024}
        directory={directory}
        dropEffect={dropEffect}
        showFileList={showFileList}
        defaultFiles={PRELOADED}
        onFilesChange={(files) => setCount(files.length)}
        localeText={TEXT}
        renderFile={row}
        renderTrigger={({ text }) => (
          <>
            <span aria-hidden="true" style={{ fontSize: 24 }}>
              ⇪
            </span>
            <br />
            {text}
          </>
        )}
      />
      <output>{count} files in the list</output>
    </div>
  );
}
```

`formatFileSize(bytes, locale)` formats sizes with 1024 steps and
`Intl.NumberFormat` unit names (`formatFileSize(1536)` is `"1.5 kB"`); the component uses it with its `locale` prop (default `'en-US'`,
never the host locale, so server and client agree).

## Events

| Event | Cancellable | When |
| --- | --- | --- |
| `onBeforeFilesAdd({ files, source })` | yes; `files` is mutable | before picked or dropped files join the list |
| `onFilesChange(files, details)` | no | after every list change |
| `onBeforeUpload({ file })` | yes | before the transport starts for a file; request parameters belong to the transport |
| `onUploadProgress(file)` | no | once per frame while uploading |
| `onUploadSuccess(file, result)`, `onUploadError(file, reason)` | no | when a file settles |
| `onUploadComplete(files)` | no | when the queue drains |
| `onBeforeRemove({ file })` | yes | before a file is removed; then the optional `remove(file, { signal })` hook runs for uploaded files |
| `onBeforeClear({ files })` | yes | before Clear or `api.clear()` |

`onBeforeFilesAdd` reports `source` (`'picker'`, `'drop'` or `'api'`);
remove entries from its `files` array to drop them from the batch, or call
`preventDefault()` to drop the whole batch. A file whose `onBeforeUpload`
was prevented stays `queued`. `api.getFiles()` returns the current entries
 and `api.remove(id)` / `api.clear()` run the same cancellable
events as the buttons.

### Live demo: FileUpload events and API

Live demo: https://salmonui.dev/demos/inputs/file-upload-events

The cancellable onBeforeFilesAdd, onBeforeUpload, onBeforeRemove and onBeforeClear events, upload success and error, api.clear and api.getFiles, formatFileSize and the keyboard and live-region behavior.

`Demo.tsx`:

```tsx
'use client';

import { useRef, useState } from 'react';
import { Button } from '@salmonui/buttons/button';
import { Checkbox } from '@salmonui/inputs/checkbox';
import { FileUpload, formatFileSize, type FileUploadApi, type UploadTransport } from '@salmonui/inputs/file-upload';
import { Select } from '@salmonui/dropdowns/select';
import { EventLog, useEventLog } from '../../components/demo-kit';

// A simulated server: about half a second per file, names containing "error" are rejected.
const simulated: UploadTransport = (file, { signal, onProgress }) =>
  new Promise((resolve, reject) => {
    let step = 0;
    const timer = setInterval(() => {
      step++;
      onProgress(Math.min(file.size, (file.size * step) / 5), file.size);
      if (step < 5) return;
      clearInterval(timer);
      if (file.name.toLowerCase().includes('error')) reject(new Error('Rejected by the server'));
      else resolve({ url: `/files/${encodeURIComponent(file.name)}` });
    }, 100);
    signal.addEventListener('abort', () => {
      clearInterval(timer);
      reject(signal.reason);
    });
  });

const MB = 1024 * 1024;

const LOCALES = ['en-US', 'de-DE', 'fr-FR', 'ja-JP'].map((value) => ({ value, label: value }));

export default function FileUploadEventsDemo() {
  const api = useRef<FileUploadApi>(null);
  const [holdLarge, setHoldLarge] = useState(false);
  const [protect, setProtect] = useState(true);
  const [keepList, setKeepList] = useState(false);
  const [locale, setLocale] = useState('en-US');
  const [listed, setListed] = useState('');
  const [log, push] = useEventLog(14);
  const size = (bytes: number) => formatFileSize(bytes, locale);

  return (
    <div style={{ display: 'grid', gap: 12, maxWidth: 480 }}>
      <div className="demo-toolbar">
        <Checkbox checked={holdLarge} onCheckedChange={(checked) => setHoldLarge(checked)}>
          Hold files over 1 MB
        </Checkbox>
        <Checkbox checked={protect} onCheckedChange={(checked) => setProtect(checked)}>
          Protect uploaded files
        </Checkbox>
        <Checkbox checked={keepList} onCheckedChange={(checked) => setKeepList(checked)}>
          Refuse clearing
        </Checkbox>
        <label>
          Size locale
          <Select aria-label="Size locale" data={LOCALES} value={locale} onValueChange={(value) => value != null && setLocale(String(value))} />
        </label>
      </div>
      <FileUpload
        ref={api}
        label="Documents"
        description="Names containing “error” fail on the simulated server"
        multiple
        upload={simulated}
        locale={locale}
        onBeforeFilesAdd={(event) => {
          const hidden = event.files.filter((f) => f.name.startsWith('.'));
          // The array is mutable: drop hidden files from the batch.
          for (const f of hidden) event.files.splice(event.files.indexOf(f), 1);
          push(`onBeforeFilesAdd ${event.source}: ${event.files.length} files${hidden.length ? `, ${hidden.length} hidden files dropped` : ''}`);
        }}
        onFilesChange={(files, d) => {
          if (d.reason !== 'progress') push(`onFilesChange ${d.reason} (${d.source}): ${files.length} files`);
        }}
        onBeforeUpload={(event) => {
          if (holdLarge && event.file.size > MB) {
            event.preventDefault();
            push(`onBeforeUpload ${event.file.name}: held (${size(event.file.size)})`);
          } else push(`onBeforeUpload ${event.file.name}`);
        }}
        onUploadSuccess={(file, result) => push(`onUploadSuccess ${file.name} -> ${(result as { url: string }).url}`)}
        onUploadError={(file, reason) => push(`onUploadError ${file.name}: ${reason instanceof Error ? reason.message : String(reason)}`)}
        onBeforeRemove={(event) => {
          if (protect && event.file.status === 'uploaded') {
            event.preventDefault();
            push(`onBeforeRemove ${event.file.name}: refused (uploaded)`);
          } else push(`onBeforeRemove ${event.file.name}`);
        }}
        onBeforeClear={(event) => {
          if (keepList) event.preventDefault();
          push(`onBeforeClear ${event.files.length} files${keepList ? ': refused' : ''}`);
        }}
      />
      <div className="demo-toolbar">
        <Button type="button" variant="outline" onClick={() => api.current?.clear()}>
          Clear with api.clear()
        </Button>
        <Button
          type="button"
          variant="outline"
          onClick={() => {
            const files = api.current?.getFiles() ?? [];
            const total = files.reduce((sum, f) => sum + f.size, 0);
            setListed(files.length ? `${files.map((f) => `${f.name} (${size(f.size)}, ${f.status})`).join('; ')}. Total ${size(total)}` : 'No files');
          }}
        >
          List with api.getFiles()
        </Button>
      </div>
      <output>{listed || 'Press List to read the files through the API'}</output>
      <EventLog entries={log} label="FileUpload events" />
    </div>
  );
}
```

## Keyboard

| Key | Action |
| --- | --- |
| Tab | Moves to the drop zone button, then Upload, Clear and each file's retry, cancel and remove buttons |
| Enter / Space on the drop zone | Opens the file picker |
| Enter / Space on a file button | Retries, cancels or removes that file |

Screen readers hear the drop zone as a button named by the label and its
text, described by the description and error. Per-file buttons are named
with the file name ("Remove report.pdf"), and settled statuses ("report.pdf:
Uploaded", "photo.png: File type not allowed") are announced through one
polite live region.

## Performance

A list of 500 files mounts within 50 ms (`tests/browser/inputs-upload.spec.ts`); a progress update re-renders only
its file's item. The subpath is about 6.5 KB gzip including the shared
field code (over the 6 KB design cap, gated at 6.8 KB; see the bundle
report), the stylesheet 1.5 KB and `file-upload/xhr` 0.7 KB.

### Live demo: FileUpload with 500 files

Live demo: https://salmonui.dev/demos/inputs/file-upload-large

A controlled FileUpload that mounts a 500-file list on demand and shows the measured render time against the 50 ms budget.

`Demo.tsx`:

```tsx
'use client';

import { useLayoutEffect, useRef, useState } from 'react';
import { Button } from '@salmonui/buttons/button';
import { FileUpload, type FileEntry, type FilePreload } from '@salmonui/inputs/file-upload';

// 500 preloaded entries with deterministic names and sizes (no randomness: SSR-safe).
const MANY: readonly FilePreload[] = Array.from({ length: 500 }, (_, i) => ({
  name: `scan-${String(i + 1).padStart(3, '0')}.pdf`,
  size: 20_000 + ((i * 7919) % 2_000_000),
  type: 'application/pdf',
}));

const NONE: readonly FileEntry[] = [];

// click to commit of a 500-file list, measured with performance.now().
export default function FileUploadLargeDemo() {
  const [files, setFiles] = useState<readonly (FileEntry | FilePreload)[]>(NONE);
  const [elapsed, setElapsed] = useState<number | null>(null);
  const start = useRef<number | null>(null);

  useLayoutEffect(() => {
    if (start.current === null) return;
    const ms = performance.now() - start.current;
    start.current = null;
    setElapsed(ms);
  }, [files]);

  return (
    <div style={{ display: 'grid', gap: 12, maxWidth: 440 }}>
      <div className="demo-toolbar">
        <Button
          type="button"
          variant="outline"
          onClick={() => {
            start.current = performance.now();
            setFiles(MANY);
          }}
        >
          Show 500 files
        </Button>
        <Button
          type="button"
          variant="outline"
          onClick={() => {
            setFiles(NONE);
            setElapsed(null);
          }}
        >
          Hide the files
        </Button>
        <output aria-live="polite">{elapsed === null ? 'Not measured yet' : `${files.length} files, mounted in ${elapsed.toFixed(1)} ms (budget 50 ms)`}</output>
      </div>
      <div style={{ maxBlockSize: 360, overflow: 'auto' }}>
        <FileUpload label="Scanned documents" multiple accept=".pdf" files={files} onFilesChange={setFiles} />
      </div>
    </div>
  );
}
```

## Server rendering

The label, drop zone, preloaded file list and live region render on the
server with the same markup as the first client render: ids come from
`useId`, sizes are formatted with the `locale` prop (default `'en-US'`,
never the host locale) and drag state is a DOM attribute, never React
state. Picked files exist only on the client. `@salmonui/inputs/file-upload/xhr`
has no React or DOM code at import time, so a server module can import it.

## Design notes

- (the upload server
  protocol: save and remove URLs, chunking, pause and resume, retries,
  chunk events). There is no Salmon-defined wire format: it would be one
  more protocol to version and host, while resumable uploads already have
  mature protocols (tus, S3 multipart, GCS resumable). The component owns
  the queue, progress and cancellation; the transport owns the wire. For a
  plain POST, pass `upload={createXhrUploader({ url })}`; for chunking,
  pause, resume and retries, use a resumable-upload client inside a custom
  `upload` function (it receives the `AbortSignal` and reports
  `onProgress`); delete files on the server in the `remove(file, { signal })`
  hook or the `onFilesChange` handler.
- there is no sort method. Sorting is a view of the `files` array
  the owner controls, so the list follows the order of `files`; sort it
  with `setFiles((f) => [...f].sort(byName))` on a controlled `files`.

## API

Every exported symbol and type is listed in the reference:
[`@salmonui/inputs/file-upload`](https://salmonui.dev/docs/reference/inputs/file-upload) and
[`@salmonui/inputs/file-upload/xhr`](https://salmonui.dev/docs/reference/inputs/file-upload-xhr).

| Prop | Type | Default |
| --- | --- | --- |
| `files`, `defaultFiles` | `(FileEntry \| { name, size, ... })[]` | `[]` |
| `onFilesChange` | `(files, { source, reason }) => void` | |
| `accept` | `string` | any |
| `multiple`, `directory` | `boolean` | `false` |
| `minSize`, `maxSize` | `number` (bytes) | |
| `maxFiles` | `number` | unlimited (`1` without `multiple`) |
| `upload` | `(file, { signal, onProgress }) => Promise<unknown>` | none: files submit with the form |
| `remove` | `(file, { signal }) => Promise<unknown>` | |
| `autoUpload` | `boolean` | `true` |
| `concurrency` | `number` | unlimited |
| `dropTarget` | `RefObject<Element \| null>` | the drop zone |
| `dropEffect` | `'copy' \| 'move' \| 'link' \| 'none'` | `'copy'` |
| `showFileList` | `boolean` | `true` |
| `renderFile`, `renderTrigger` | see above | |
| `label`, `description`, `errorMessage`, `invalid`, `validation`, `validateOn`, `size` | as in [Field](https://salmonui.dev/docs/inputs/field) | |
| `localeText` | `{ browse, uploadAll, clearAll, removeFile, cancelFile, retryFile, filesAdded, queued, uploading, uploaded, error, canceled, type, tooSmall, tooLarge, tooMany, upload, remove, validation* }` | English |
| `onBeforeFilesAdd`, `onBeforeUpload`, `onBeforeRemove`, `onBeforeClear`, `onUploadProgress`, `onUploadSuccess`, `onUploadError`, `onUploadComplete` | see [Events](https://salmonui.dev/docs/inputs/file-upload#events) | |
| `locale` | `string` | `'en-US'` |
| `classNames` | `{ trigger, list, item, label, description, error }` | |
| `ref` | `Ref<FileUploadApi>` | |
| other props | `name`, `form`, `required`, `disabled`, `capture`, `id`, `aria-*`, `data-*`, `onChange` | on the native input |

`FileUploadApi`: `element`, `upload(ids?)`, `cancel(id)`, `retry(id)`,
`remove(id)`, `clear()`, `getFiles()`, `open()`, `focus()`.

`createXhrUploader({ url, method, headers, fieldName, data, withCredentials })`
sends one multipart request per file with upload progress, aborts through
the signal, resolves with `{ status, body }` on 2xx and rejects with an
`XhrUploadError` (`status`, `body`) otherwise. `url`, `headers` and `data`
may be functions of the file.
