---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# File upload

A drop zone or a button to choose files, for attachments, an import or a photo, with a list of the chosen files, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `FileUpload`.

## Try it

Drop, choose or paste files and watch each upload; a file named with “fail” fails part way and goes through on Retry; remove a row mid-upload to stop it; a too large file or a seventh is refused. Change the profile photo with the small trigger. Pick a look: the zone turned off, or refusing a file under its error line.

The upload is a timer (about three seconds a file, no request); nothing is stored and the photo never leaves the page.

## When to use

- A drop zone or a button to choose files, for attachments, an import or a photo, with a list of the chosen files.
- Also called: dropzone or file input.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same File upload on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-file-upload.json --yes
```

```text
Add the Goop File upload to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { FileUploadList, FileUploadItem } from '@/components/ui/goop/file-upload';

import {
  FileUpload,
  FileUploadDropzone,
  type FileUploadSend,
  FileUploadTrigger,
  formatFileSize,
} from '@/components/ui/goop/file-upload';

const send: FileUploadSend = async (file, { onProgress, signal }) => {
  const body = new FormData();
  body.append('plan', file);
  onProgress(10);
  const reply = await fetch('/api/site-plans', { method: 'POST', body, signal });
  if (!reply.ok) throw new Error('The plan was not stored. Try again.');
  return reply.json();
};

function SitePlans() {
  return (
    <FileUpload accept=".pdf,image/*" maxSize={10_000_000} upload={send} concurrency={2}>
      <FileUploadDropzone hint={`PDF or image, up to ${formatFileSize(10_000_000)}`} />
    </FileUpload>
  );
}

function ChangePhoto({ onPhoto }: { onPhoto: (photo: File) => void }) {
  return (
    <FileUpload accept="image/*" multiple={false} onFilesAdd={([photo]) => photo && onPhoto(photo)}>
      <FileUploadTrigger>Change photo</FileUploadTrigger>
    </FileUpload>
  );
}
```

- Fits: flow, settings, record: field.
- Also known as: Dropzone, FileInput, Uploader, FilePicker, Input type="file".
- Shortest: `<FileUpload upload={send}><FileUploadDropzone /></FileUpload>`, where `send(file, { onProgress, signal })` is your request; or `<FileUpload onFilesAdd={keep}>` and your own FileUploadItems. Keep one zone or one trigger per upload; the trigger alone sits as wide as its button, beside a picture or in a row. Point a label at the control with the upload's `id`; a hint under the zone's words takes `hint`.
- height, width, padding, gap, corner, background, shadow, text, motion: add no class for these.

## API reference

### Parts

- `FileUploadDropzone` — The drop zone; its props: file-upload--dropzone.md
- `FileUploadTrigger` — The button that opens the file chooser; also takes type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'
- `FileUploadList` — The list of chosen files
- `FileUploadItem` — One chosen file, as your code holds it (or as the upload lists it when it runs your `upload` function); its props: file-upload--item.md
- `formatFileSize` — A file's size as a person writes it, in thousands

- data-slot values (to select a part by): file-upload, file-upload-box, file-upload-description, file-upload-icon, file-upload-icon-box, file-upload-input, file-upload-item, file-upload-item-actions, file-upload-item-content, file-upload-item-icon, file-upload-item-indicator, file-upload-item-label, file-upload-item-media, file-upload-item-progress, file-upload-item-text, file-upload-list, file-upload-status, file-upload-text, file-upload-title, file-upload-trigger

### FileUploadDropzone

The drop zone.

```tsx
import { FileUploadDropzone } from '@/components/ui/goop/file-upload';
```

### Options

- hint?: ReactNode — A grey line under the words, describing the zone: the types and the limits ("CSV, up to 5 MB").
- children?: ReactNode — The zone's words; left out, "Drop files here, or choose them" ("Drop a file here, or choose one" for one file).
- Also takes: onClick?: (event: MouseEvent) => void; disabled?: boolean

### FileUploadItem

One chosen file, as your code holds it (or as the upload lists it when it runs your `upload` function).

```tsx
import { FileUploadItem } from '@/components/ui/goop/file-upload';
```

### Options

- name: string — The file's name, cut with an ellipsis where too long.
- bytes?: number — The file's size in bytes, shown as a person writes it ("2.4 MB").
- status?: 'queued' | 'uploading' | 'done' | 'error' = 'queued' — `queued`, `uploading` (with `progress`), `done` (a green check) or `error` (with `error`).
- progress?: number — How far the upload has gone, 0–100, while `uploading`.
- error?: ReactNode — While `error`: what went wrong and how to put it right ("Only .csv files.").
- file?: File — The chosen file: an image is shown as a small thumbnail in place of the file icon.
- media?: ReactNode — A thumbnail of your own before the name, in place of the file's type icon.
- onRemove?: () => void — Called by the row's Remove button; none, and the row shows none.
- onRetry?: () => void — Called by the row's Retry button, shown while `error`; none for a refused file.

### FileUpload: every option

```tsx
import { FileUpload } from '@/components/ui/goop/file-upload';
```

### Options

- accept?: string — The file types offered and taken, as the input's `accept` (`.csv`, `image/*`); any if left out.
- multiple?: boolean = true — Whether several files may be chosen at once (default true); false offers one, and refuses the rest of a drop.
- maxFiles?: number — The most files the upload holds (its rows, an error row aside; without rows, one choice); past it they are refused.
- maxSize?: number — The largest file taken, in bytes; a larger one is refused.
- disabled?: boolean = false — Turns the zone and the trigger off: nothing opens the picker, marks the zone or adds a file.
- onFilesAdd?: (accepted: File[], refused: FileUploadRefusal[]) => void — Called on each choice, drop or paste with the files that passed the checks and those refused (each with its reason).
- upload?: FileUploadSend — Your upload function.
- concurrency?: number = 3 — With `upload`: how many files are sent at once (3 by default); the rest wait, queued, in their order.
- onUploadsChange?: (uploads: FileUploadEntry[]) => void — With `upload`: called with every file the upload holds each time one changes.
- id?: string — The zone's or the trigger's id: a label beside the upload points at it.
- aria-describedby?: string — What else describes the zone or the trigger (a field's description, its error).
- aria-invalid?: boolean | 'true' | 'false' — Marks the zone or the trigger invalid: the zone's edge takes the danger colour.
- Types: FileUploadRefusal = { file: File; reason: FileUploadRefusalReason }; FileUploadSend = (file: File, options: FileUploadSendOptions) => Promise<unknown>; FileUploadEntry = { id: string; file: File; status: FileUploadStatus; progress: number; error?: string; result?: unknown; refused?: FileUploadRefusalReason }

## Keyboard

- Enter / Space: open the file chooser

## Accessibility

- The native element answers the keyboard.
- hover, active: the browser's own (:hover, :active): write nothing
- focus-visible: the attribute data-focus-visible
- dragging: the attribute data-dragging
- disabled: the prop disabled
- invalid: the attribute aria-invalid

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Calendar](/themes/meadow/components/calendar): A month always in view, to choose a date or a range of dates.
- [Date picker](/themes/meadow/components/date-picker): A field that opens a month to choose one date, typed or picked.
- [Month and year list](/themes/meadow/components/date-picker-choices): A month list or a year list in a month's caption, for a far date such as a date of birth.
- [Date range picker](/themes/meadow/components/date-range-picker): A field that opens a calendar to choose a range of dates, with presets beside it when given.
