# Attachment

Files attached to a message, with real upload progress and previews.

- **Use it for**: Files attached to a message, with measured upload progress.
- **Not for**: Picking files. Try [FileDropzone](https://unseenui.com/components/file-dropzone/).

## Good to know

- Media types show as short names such as CSV, PDF or "PNG image".
- Ready is announced to screen readers but not shown; other upload states are shown.

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Attachment } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Attachment variant="row" name="brief.pdf" state="ready" onRemove={remove} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `access` | `AttachmentAccess` |  |
| `detail` | `string` |  |
| `mediaType` | `string` |  |
| `name` (required) | `string` |  |
| `onOpen` | `(() => void)` | Host opens an authorized original; the component never downloads automatically. |
| `onRemove` | `(() => void)` |  |
| `onRetry` | `(() => void)` |  |
| `preview` | `AttachmentPreviewSource` |  |
| `progress` | `{ loaded: number; total: number; }` | Measured byte counts from the upload delegate; never a simulated percentage. |
| `reference` | `AttachmentReference` | Requested immutable file version. |
| `resource` | `AttachmentReference` | Identity of the supplied metadata/preview. |
| `sizeBytes` | `number` |  |
| `state` (required) | `AttachmentState` |  |
| `variant` | `"compact" \| "row" \| "tile"` |  |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[Chat](https://unseenui.com/components/chat/), [PromptInput](https://unseenui.com/components/prompt-input/), [Message](https://unseenui.com/components/message/), [StreamingResponse](https://unseenui.com/components/streaming-response/), [MessageActions](https://unseenui.com/components/message-actions/), [Suggestions](https://unseenui.com/components/suggestions/), [AttachmentTray](https://unseenui.com/components/attachment-tray/), [FileDropzone](https://unseenui.com/components/file-dropzone/), [ModelSelector](https://unseenui.com/components/model-selector/), [FeedbackCapture](https://unseenui.com/components/feedback-capture/), [Reasoning](https://unseenui.com/components/reasoning/), [SuggestTextarea](https://unseenui.com/components/suggest-textarea/)

Page: https://unseenui.com/components/attachment/
