npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-file-upload.json --yesFile upload
ProA drop zone or a button to choose files, with a list of the chosen files and their sizes, for attachments, imports or a photo, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- FileUploadDropzoneThe drop zone
- FileUploadTriggerThe button that opens the file chooser
- FileUploadListThe list of chosen files
- FileUploadItemOne chosen file, as your code holds it (or as the upload lists it when it runs your
uploadfunction) - formatFileSizeA file's size as a person writes it, in thousands
import { formatFileSize, FileUpload, FileUploadDropzone, FileUploadTrigger, FileUploadList, FileUploadItem } from '@/components/ui/goop/file-upload';
import { Field } from '@/components/ui/goop/field';
import { Avatar, AvatarFallback } from '@/components/ui/goop/avatar';
function Uploads() {
return (
<>
<Field orientation="vertical" label="Attachments" className="w-full">
<FileUpload
maxSize={10_000_000}
upload={async (file, { onProgress, signal }) => {
// your request goes here, handed `signal` so a removed row stops it
for (let share = 20; share <= 100; share += 20) {
await new Promise((done) => setTimeout(done, 300));
signal.throwIfAborted();
onProgress(share);
}
return file.name;
}}
onUploadsChange={(uploads) =>
send(uploads.filter((entry) => entry.status === 'done').map((entry) => entry.result))
}
>
<FileUploadDropzone hint="Any file up to 10 MB, or paste one" />
</FileUpload>
</Field>
<Field label="Profile photo">
{(control) => (
<div className="flex items-center gap-3">
<Avatar name="Teodora Valk">
<AvatarFallback>TV</AvatarFallback>
</Avatar>
<FileUpload accept="image/*" multiple={false} onFilesAdd={(accepted) => attach(accepted[0])} {...control}>
<FileUploadTrigger>Change photo</FileUploadTrigger>
</FileUpload>
</div>
)}
</Field>
</>
);
}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, with a list of the chosen files and their sizes, for attachments, imports or a photo.
- 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.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-file-upload.json --yesAdd the Goop File upload to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { formatFileSize, FileUpload, FileUploadDropzone, FileUploadTrigger, FileUploadList, FileUploadItem } from '@/components/ui/goop/file-upload';
import { Field } from '@/components/ui/goop/field';
import { Avatar, AvatarFallback } from '@/components/ui/goop/avatar';
function Uploads() {
return (
<>
<Field orientation="vertical" label="Attachments" className="w-full">
<FileUpload
maxSize={10_000_000}
upload={async (file, { onProgress, signal }) => {
// your request goes here, handed `signal` so a removed row stops it
for (let share = 20; share <= 100; share += 20) {
await new Promise((done) => setTimeout(done, 300));
signal.throwIfAborted();
onProgress(share);
}
return file.name;
}}
onUploadsChange={(uploads) =>
send(uploads.filter((entry) => entry.status === 'done').map((entry) => entry.result))
}
>
<FileUploadDropzone hint="Any file up to 10 MB, or paste one" />
</FileUpload>
</Field>
<Field label="Profile photo">
{(control) => (
<div className="flex items-center gap-3">
<Avatar name="Teodora Valk">
<AvatarFallback>TV</AvatarFallback>
</Avatar>
<FileUpload accept="image/*" multiple={false} onFilesAdd={(accepted) => attach(accepted[0])} {...control}>
<FileUploadTrigger>Change photo</FileUploadTrigger>
</FileUpload>
</div>
)}
</Field>
</>
);
}- Fits: flow, settings, record: field.
- Also known as: Dropzone, FileInput, Uploader, FilePicker, Input type="file".
- Use FileUpload where a form takes files — a zone for an import or attachments, the trigger beside a picture (an Avatar's "Change photo"). Shortest:
<FileUpload upload={send}><FileUploadDropzone /></FileUpload>, wheresend(file, { onProgress, signal })is your request; read the results fromonUploadsChange. To hold the rows yourself, leaveuploadout and list FileUploadItems fromonFilesAdd. Keep one zone or one trigger per upload. A vertical Field holding the zone takesclassName="w-full": the field's column is otherwise as wide as its label, and the zone fills the column. - More on where it goes: file-upload--options.md
- height, width, padding, gap, corner, border, background, text, motion: add no class for these.
API reference
- Each option with its sentence: file-upload--options.md
| Part | What it is |
|---|---|
| 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-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-text, file-upload-list, file-upload-status, file-upload-title, file-upload-trigger
FileUploadDropzone
The drop zone.
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" ("Choose files" on a phone).
- 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).
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(withprogress),done(a green check) orerror(witherror). - 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
import { FileUpload } from '@/components/ui/goop/file-upload';Compose
- A chat's attachments are ComposerAttach's; showing the chosen picture is an Avatar's or a MediaFrame's job.
Options
- accept?: string — The file types taken, as the input's
accept(.csv,image/*); any if left out. - multiple?: boolean = true — Whether several files may be chosen at once; false offers one, and refuses the rest of a drop.
- maxFiles?: number — The most files the upload holds (an error row aside); 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; a field holding the upload hands it on.
- onFilesAdd?: (accepted: File[], refused: FileUploadRefusal[]) => void — Called on each choice, drop or paste with the files taken and those refused (each with its reason).
- upload?: FileUploadSend — Your upload function.
- concurrency?: number = 3 — With
upload: how many files are sent at once; 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 field holding the upload points its label at it.
- aria-describedby?: string — What else describes the zone or the trigger.
- aria-invalid?: boolean | 'true' | 'false' — Marks the zone or the trigger invalid (a FieldInvalid sets it).
- 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
| Key | What it does |
|---|---|
| Enter | Choose files |
| Space | Choose files |
Accessibility
- The native element answers the keyboard.
- hover, focus-visible: the browser's own (:hover, :focus-visible): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| 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.
- How the theme moves, and how to move your own parts the same way: Motion.
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.