---
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/"
---

# Attachment list

The files chosen to send, under a composer or a form field, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `AttachmentList`.

## Try it

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 an `upload` function 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.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-attachment-list.json --yes
```

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

## Usage

```tsx
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

### Options

- `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 }

## Keyboard

- 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
- 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.

## Related

- [Composer](/themes/trail/components/composer): A box to write a message, a comment or a prompt in, with attachments and a send button, for a chat or a record's comments.
- [Message list](/themes/trail/components/message-list): The messages of one conversation in a column, the newest at one end, as they arrive.
- [Chat message](/themes/trail/components/chat-message): One message of a conversation: its author, its body and when it was sent, often an avatar and actions.
