npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-attachment-list.json --yesAttachment list
ProThe files chosen to send, under a composer or a form field, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
import { AttachmentList } from '@/components/ui/goop/attachment-list';
import { useState } from 'react';
import { Composer, ComposerEditor, ComposerToolbar, ComposerActions, ComposerAttach, ComposerSubmit } from '@/components/ui/goop/composer';
function Message() {
const [files, setFiles] = useState<Parameters<typeof AttachmentList>[0]['files']>([]);
return (
<Composer onSubmit={send}>
<ComposerEditor aria-label="Message" placeholder="Write to the team" />
<AttachmentList files={files} onRemove={(file) => setFiles((all) => all.filter((one) => one !== file))} />
<ComposerToolbar>
<ComposerActions>
<ComposerAttach
aria-label="Attach files"
onFilesChange={(chosen) =>
setFiles((all) => [...all, ...chosen.map(({ name, size, type }) => ({ name, size, type }))])
}
/>
<ComposerSubmit aria-label="Send" />
</ComposerActions>
</ComposerToolbar>
</Composer>
);
}Attach files with the paperclip and watch each bar fill; remove one with its cross, or Tab onto it and press Backspace or Delete. A file named with “fail” stops part way with its sentence; one over 25 MB is refused. Pick a look: the same files as rows under a form field. The upload is a timer (about three seconds a file, no request); nothing is stored and no file leaves the page.
When to use
- The files chosen to send, under a composer or a form field.
- Use AttachmentList wherever a person chooses files before sending: in a Composer between the ComposerEditor and the ComposerToolbar, fed from ComposerAttach's
onFilesChange; under a Field holding a FileUploadTrigger. A FileUpload with anuploadfunction lists its own rows.
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 Attachment list 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-attachment-list.json --yesAdd the Goop Attachment list to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { AttachmentList } from '@/components/ui/goop/attachment-list';
import { useState } from 'react';
import { Composer, ComposerEditor, ComposerToolbar, ComposerActions, ComposerAttach, ComposerSubmit } from '@/components/ui/goop/composer';
function Message() {
const [files, setFiles] = useState<Parameters<typeof AttachmentList>[0]['files']>([]);
return (
<Composer onSubmit={send}>
<ComposerEditor aria-label="Message" placeholder="Write to the team" />
<AttachmentList files={files} onRemove={(file) => setFiles((all) => all.filter((one) => one !== file))} />
<ComposerToolbar>
<ComposerActions>
<ComposerAttach
aria-label="Attach files"
onFilesChange={(chosen) =>
setFiles((all) => [...all, ...chosen.map(({ name, size, type }) => ({ name, size, type }))])
}
/>
<ComposerSubmit aria-label="Send" />
</ComposerActions>
</ComposerToolbar>
</Composer>
);
}- Fits: chat, inbox: field.
- Also known as: Attachments, AttachmentChips, FileList, FileChips, UploadList.
- height, width, padding, gap, corner, background: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| files | readonly AttachmentFile[] | The chosen files, in their order: one chip or row each. |
| onRemove? | (file: AttachmentFile, index: number) => void | Called by a file's Remove button, or Backspace or Delete on the file, with the file and its place in files: take it out of your list. |
| variant? | 'chips' | 'list' = 'chips' | chips a wrapping row of chips, under a composer; list full-width rows, under a form field. |
| aria-label? | string = 'Attachments' | The list's name for a screen reader. |
- Types: AttachmentFile = { id?: string; name: string; size?: number; type?: string; progress?: number; error?: ReactNode }
- data-slot values (to select a part by): attachment-list, attachment-list-content, attachment-list-error, attachment-list-item, attachment-list-item-close, attachment-list-item-content, attachment-list-item-icon, attachment-list-item-label, attachment-list-item-text, attachment-list-status
Keyboard
| Key | What it does |
|---|---|
| Tab | Move to the next file (each file is one tab stop; its Remove is the pointer's) |
| Backspace | Remove the focused file; the focus moves to the next file, else the previous one, else the control before the list |
| Delete | Remove the focused file, as Backspace |
Accessibility
- The part itself answers the keys above.
- focus-visible: the browser's own (: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 |
|---|---|
| invalid | the attribute data-invalid |
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.