# Attachment
A composable attachment surface for files and images, including media, metadata, upload state, and actions.
## Use cases
- **Use**: File attachments in chat composers, message threads, and upload lists
- **Use**: Image attachments with thumbnails, names, sizes, and remove actions
- **Use**: Attachments that need idle, uploading, processing, error, and done states
- **Don't use**: Full file-manager workflows, which belong in a dedicated page
## Usage
```tsx
import {
Attachment,
AttachmentAction,
AttachmentActions,
AttachmentContent,
AttachmentDescription,
AttachmentMedia,
AttachmentTitle,
} from "@lcui/react"
```
```tsx
sales-dashboard.pdf
PDF · 2.4 MB
```
## Composition
Use the following composition to build an `Attachment`:
```
Attachment
├── AttachmentMedia
├── AttachmentContent
│ ├── AttachmentTitle
│ └── AttachmentDescription
├── AttachmentActions
│ └── AttachmentAction
└── AttachmentTrigger
```
Use `AttachmentGroup` to lay out multiple attachments in a row:
```
AttachmentGroup
├── Attachment
└── Attachment
```
## Examples
### Image
Set `variant="image"` on `AttachmentMedia` and provide an image through `src` or a background image. With vertical orientation the media sits above the content, which suits image thumbnails.
### States
`state` describes the upload lifecycle. `uploading` and `processing` add a Shimmer sweep to the title, and the media slot can hold a Spinner.
### Sizes
Use `size` to switch between `default`, `sm`, and `xs`.
### Group
The basic example arranges three image attachments in an `AttachmentGroup`. Each attachment keeps its own size, and actions remain independently clickable.
### Trigger
`AttachmentTrigger` is an absolutely positioned transparent layer that covers the whole card while leaving `AttachmentActions` clickable. Attachments with a trigger show a `bg-muted/50` background on hover and use a box-shadow instead of an outline for active/focus. Wire the click through declarative associations such as `data-dialog-trigger` to a preview, link, or dialog.
## API Reference
### Attachment
The attachment root. Manages state, size, and orientation.
### AttachmentMedia
The leading or top media slot for an icon or image preview.
### AttachmentContent
The flexible content slot for the title and description.
### AttachmentTitle
The attachment name. Uploading and processing states show a Shimmer sweep.
### AttachmentDescription
Secondary metadata such as file type, size, or upload status.
### AttachmentActions
The action slot. Vertically oriented attachments pin it to the top right.
### AttachmentAction
An icon action button based on the `ghost` button variant and `icon-xs` size.
### AttachmentTrigger
A transparent full-card trigger layer that sits below the actions.
### AttachmentGroup
A row container for multiple attachments.