---
title: "File Trigger"
description: "A button that opens the file picker and gives the picked files to the app, with no list and no checks."
url: https://gelatinui.com/components/file-trigger
markdown_url: https://gelatinui.com/components/file-trigger.md
access: free
install: "npx shadcn@latest add @gelatin-ui/file-trigger"
registry_item: https://gelatinui.com/r/file-trigger.json
version: "2026-11-16"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# File Trigger

> A button that opens the file picker and gives the picked files to the app, with no list and no checks.

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

## When to use it

Best for: A Button or a menu item that opens the file picker and gives the files to your code.

- Use `onSelect` to get the files.
- Use `accept`, `multiple`, or `directory` for the pick.
- Use `render={<MenuItem />}` to make a source menu item that opens the picker.
- Use `actionsRef` to open the picker from a shortcut, in the press itself.

## When not to use it

- When the form must hold and show the files, use a [File Input](https://gelatinui.com/components/file-input.md).
- For a large drop area, use a [Dropzone](https://gelatinui.com/components/dropzone.md).

## Notes for agents

- It has no list and no checks: the app decides.
- Any Button variant and size pass through.
- `busy` shows the Button spinner in the leading slot, so the label stays. A busy or disabled trigger opens nothing.
- `onSelect` does not run on a cancel. A blocked picker calls `onPickError` (default `reportError`).
- It keeps the Button `data-slot`; select it with `[data-part=file-trigger]`.

## Anatomy

```text
FileTrigger
```

## API reference

### FileTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` | false | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` | "start" | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |
| `onSelect` | `function` |  | The picked files, after each pick (also the same file again). It does not run on a cancel. |
| `onPickError` | `function` |  | A pick that fails (a picker blocked in a cross-origin frame). Default: `reportError`. |
| `accept` | `string` |  | The types the picker offers (`accept` of the file input): ".csv", "image/*", … |
| `multiple` | `boolean` | false | More than one file in one pick. Default `false`. |
| `directory` | `boolean` | false | The picker chooses a folder (`webkitdirectory`), and every file in it comes back. |
| `capture` | `"environment" \| "user" \| boolean` |  | The camera on a phone (`capture`): `"user"` (front) or `"environment"` (back). |
| `actionsRef` | `RefObject<{ open: () => void; } \| null>` |  | Gets `open`: the picker, called in a user press (a menu item, a shortcut). |
| `render` | `ComponentRenderFn \| ReactElement` |  | Another element to press instead of the Button: `render={<MenuItem />}` makes a menu item that opens the picker (a source menu). It gets the press and `data-popup-open` only. |

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

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| FileTrigger | `file-trigger` |  |  |  |

## Usage

Put the icon and the words in `FileTrigger` as children. `onSelect` gets the picked files; your app checks and sends them.

```tsx title="import-contacts.tsx"
import { FileTrigger } from "@/components/ui/file-trigger";
import { UploadSimpleIcon } from "@phosphor-icons/react/ssr";
import { useState } from "react";

export function ImportContacts() {
  const [busy, setBusy] = useState(false);

  async function importFiles(files: File[]) {
    setBusy(true);
    const body = new FormData();
    for (const file of files) {
      body.append("contacts", file);
    }
    try {
      await fetch("/api/contacts/import", { method: "POST", body });
    } finally {
      setBusy(false);
    }
  }

  return (
    <FileTrigger accept=".csv" multiple busy={busy} onSelect={importFiles}>
      <UploadSimpleIcon data-icon="inline-start" aria-hidden />
      Import contacts
    </FileTrigger>
  );
}
```

## 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-trigger
```

It adds 11 registry items: 8 files, 1747 lines, and the npm packages `@base-ui/react`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Button](https://gelatinui.com/components/button.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

- [Button](https://gelatinui.com/components/button.md)
- [Menu](https://gelatinui.com/components/menu.md)
- [Dropzone](https://gelatinui.com/components/dropzone.md)
- [File Input](https://gelatinui.com/components/file-input.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space | Opens the file picker. |

## Accessibility

It is a native `<button>`: Enter and Space open the picker.

An icon-only trigger needs an `aria-label`.

## Motion

| Part | Motion |
| --- | --- |
| Press | press · 100ms · ease-out (0, 0, 0.2, 1) · the Button moves down 1px |
| Picker open | hover · 150ms · ease-out (0, 0, 0.2, 1) · the hover fill stays while the picker is open (`data-popup-open`) |
