---
title: "File Input"
description: "A form field that holds files: it looks like an Input, opens the file picker, takes a drop, and checks the picked files with the Dropzone rules."
url: https://gelatinui.com/components/file-input
markdown_url: https://gelatinui.com/components/file-input.md
access: free
install: "npx shadcn@latest add @gelatin-ui/file-input"
registry_item: https://gelatinui.com/r/file-input.json
version: "2026-11-16"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# File Input

> A form field that holds files: it looks like an Input, opens the file picker, takes a drop, and checks the picked files with the Dropzone rules.

Page: https://gelatinui.com/components/file-input

## When to use it

Best for: A file in a form row: one line high, with the picker, a drop, the checks, and the upload state.

- Use it in a form next to text fields, where a large drop area takes too much space.
- Use `multiple` and `FileInputMore` to show many files in one row, with a list in a popover.
- Pass `uploads` from `useFileUploads` to show the percent, the done check, and Retry in the field.
- Put it in a Base UI `Field` to get the label, the help, `required`, and the error.

## When not to use it

- For a large drop area with sources and a file list, use a [Dropzone](https://gelatinui.com/components/dropzone.md).
- For a button that only gives the files to your code, use a [File Trigger](https://gelatinui.com/components/file-trigger.md).

## Notes for agents

- It is the Dropzone root: `accept`, `maxSize`, `maxFiles`, `validator`, and the form props pass through. `noKeyboard` stays on.
- `FileInputValue` is the one tab stop and the press target. Its `::after` covers the box; the add-ons sit above it.
- One file by default. Set `multiple` for more; `valueDisplay="count"` writes "3 files".
- Add `DropzoneRejections` under `FileInputControl`, or the reasons for a rejected file do not show.
- The component never uploads. Pass `useFileUploads` as `uploads`: a pick goes to `uploads.sync`.
- `labels` holds the field words and the Dropzone words in one object. Keep the object stable.

## Anatomy

```text
FileInput
├─ FileInputControl (0..n)
├─ FileInputPreview (0..n)
├─ FileInputValue (0..n)
├─ FileInputMore (0..n)
├─ FileInputProgress (0..n)
├─ FileInputRetry (0..n)
├─ FileInputClear (0..n)
└─ FileInputTrigger (0..n)
```

## API reference

### FileInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `accept` | `Accept \| AcceptGroup[]` |  |  |
| `minSize` | `number` |  |  |
| `maxSize` | `number` |  |  |
| `maxFiles` | `number` |  |  |
| `preventDropOnDocument` | `boolean` |  |  |
| `noDrag` | `boolean` |  |  |
| `noDragEventsBubbling` | `boolean` |  |  |
| `noPaste` | `boolean` |  | If true, disables paste-to-upload. By default, when the dropzone (or a focused child) receives a paste that carries files - e.g. a screenshot pasted with Ctrl/Cmd+V - those files go through the same `accept`/size/`validator` checks and `onDrop` callbacks as a drop. Pastes with no files (plain text, etc.) are ignored and left untouched. See https://github.com/react-dropzone/react-dropzone/issues/1210 |
| `disabled` | `boolean` |  |  |
| `onDrop` | `function` |  |  |
| `onDropAccepted` | `function` |  |  |
| `onDropRejected` | `function` |  |  |
| `getFilesFromEvent` | `function` |  |  |
| `onFileDialogCancel` | `function` |  |  |
| `onFileDialogOpen` | `function` |  |  |
| `onError` | `function` |  |  |
| `validator` | `function` |  | Custom validation, run once per file on drop/selection. Return `null` to accept the file, or a FileError (or array of them) to reject it. May be `async` (return a `Promise`) to support checks that can't run synchronously - e.g. reading image dimensions, inspecting file contents, or calling an external service. While an async validator is pending, DropzoneState.isProcessing is `true`, and `onDrop`/`onDropAccepted`/`onDropRejected` fire only once it settles. If the validator throws or rejects, `onError` is called and the drop is discarded. Note: the validator never runs during a drag (a `DataTransferItem` has no name/size), so a validator-configured dropzone is `isDragUnknown` until drop. |
| `getErrorMessage` | `function` |  | Override the message of any rejection error (built-in or custom). Called once per error; receives the error and the file it belongs to and returns the message to use. Return `error.message` for codes you don't want to change. Useful for localizing error messages. |
| `useFsAccessApi` | `boolean` |  |  |
| `autoFocus` | `boolean` |  |  |
| `files` | `readonly File[]` |  | The accepted files (controlled). |
| `defaultFiles` | `readonly File[]` |  | The accepted files at first (uncontrolled). |
| `onFilesChange` | `function` |  | Runs when a drop, a pick, a paste, or a remove changes the list. |
| `name` | `string` |  | The form field name: a normal form submit sends the files under it. |
| `required` | `boolean` |  | The form needs at least one file (native validation on submit). |
| `readOnly` | `boolean` |  | The list shows, but nothing adds files: no dialog (also not from a label click), no drop, and no paste; the trigger is off. Render no remove buttons then. Default `false`. |
| `invalid` | `boolean` |  | Shows the area as invalid (a red edge), for an error that the app sets. |
| `noClick` | `boolean` |  | A click on the area does not open the dialog; only the trigger does. Default `false`. |
| `locale` | `LocalesArgument` |  | The locale of the sizes in the messages and the file list. |
| `directory` | `boolean` |  | The dialog picks a folder (`webkitdirectory`), and every file in it is added. A dropped folder always works. Not with `useFsAccessApi`: that picker cannot choose folders. |
| `capture` | `"environment" \| "user" \| boolean` |  | The camera on a phone (`capture` of the file input): `"environment"` (back) or `"user"` (front). Android opens only the camera then. For a choice of camera or gallery, use two Dropzones, each with its own trigger. |
| `actionsRef` | `RefObject` |  | Gets `open` (the file dialog, for a menu item or a shortcut, in the press itself), `clear` (empties the list), and `clearRejections`. |
| `className` | `string` |  |  |
| `children` | `ReactNode` |  |  |
| `rounded` | `"default" \| "full"` | "default" |  |
| `size` | `ControlSizeAtLeastSm` | "default" | 28, 32, or 36px: the field sizes of `controlVariants` that the field has. |
| `uploads` | `FileUploadsSource` |  | The list and its uploads (`useFileUploads`): the field shows the files of `uploads`, sends a pick to `uploads.sync`, and shows the progress, the done check, and Retry. |
| `labels` | `Partial` |  | Every word: the field words (`FileInputLabels`) and the Dropzone words (`DropzoneLabels`, the messages of a wrong file) in one object. Keep the object stable. |

### FileInputControl

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  |  |

### FileInputPreview

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | The icon of a field with no picture. Default a paperclip. |

### FileInputValue

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `placeholder` | `string` |  | The text when the list is empty. Default the `placeholder` word of the labels. |
| `valueDisplay` | `"count" \| "first"` | "first" | How many files read: `first` ("receipt.jpg +2", default) or `count` ("3 files"). One file always shows its name. |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### FileInputMore

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `rounded` | `"default" \| "full"` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### FileInputProgress

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### FileInputRetry

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `rounded` | `"default" \| "full"` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### FileInputClear

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `rounded` | `"default" \| "full"` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### FileInputTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "secondary" |  |
| `size` | `"xs"` | "xs" |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| FileInput | `file-input` |  |  |  |
| FileInputControl | `file-input-control` | `data-dialog-open`, `data-drag-active`, `data-drag-global`, `data-drag-reject`, `data-part` |  | `status-colors` |
| FileInputPreview | `file-input-preview` | `data-size` | `--radius` |  |
| FileInputValue | `file-input-value` | `data-disabled` |  |  |
| FileInputMore | `file-input-more` |  |  |  |
| FileInputProgress | `file-input-progress` |  |  | `motion-timing`, `status-colors` |
| FileInputRetry | `file-input-retry` |  |  |  |
| FileInputClear | `file-input-clear` |  |  |  |
| FileInputTrigger | `file-input-trigger` |  |  |  |

## Usage

Compose the field box with its parts inside `FileInput`. The checks are the Dropzone checks, so `DropzoneRejections` shows why a file did not fit.

```tsx title="invoice-field.tsx"
import { DropzoneRejections } from "@/components/ui/dropzone";
import {
  FileInput,
  FileInputClear,
  FileInputControl,
  FileInputPreview,
  FileInputTrigger,
  FileInputValue,
} from "@/components/ui/file-input";

export function InvoiceField() {
  return (
    <FileInput
      name="invoice"
      accept={{ "application/pdf": [".pdf"] }}
      maxSize={10_000_000}
    >
      <FileInputControl>
        <FileInputPreview />
        <FileInputValue placeholder="Choose the March invoice" />
        <FileInputClear />
        <FileInputTrigger />
      </FileInputControl>
      <DropzoneRejections />
    </FileInput>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/file-input
```

It adds 74 registry items: 70 files, 13723 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `clsx`, `motion`, `react-dropzone`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Circular Progress](https://gelatinui.com/components/circular-progress.md)
- [Dropzone](https://gelatinui.com/components/dropzone.md)
- [File Icon](https://gelatinui.com/components/file-icon.md)
- [Input Group](https://gelatinui.com/components/input-group.md)
- [Popover](https://gelatinui.com/components/popover.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Input](https://gelatinui.com/components/input.md)
- [Input Group](https://gelatinui.com/components/input-group.md)
- [Field](https://gelatinui.com/components/field.md)
- [Dropzone](https://gelatinui.com/components/dropzone.md)
- [File Trigger](https://gelatinui.com/components/file-trigger.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space | On `FileInputValue` or `FileInputTrigger`: opens the file picker. |
| ⌘V, Ctrl+V | Focus on a part of the field: pastes files. |

## Accessibility

`FileInputValue` is a button. Its name is the file name, or the placeholder when the field is empty.

In a Base UI `Field`, the label names the value button, and the help and the error describe it.

A full list keeps the value button in the tab order with `aria-disabled`.

An invalid field, or a failed upload, sets `aria-invalid` on the value button.

## Motion

| Part | Motion |
| --- | --- |
| Upload bar | indicator · 200ms · ease-panel (0.2, 0.4, 0.2, 1) · the 2px bar on the bottom edge grows with the bytes |
| File list | popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · the "+2" popover fades in and scales from 95% |
