Attachments
Files hanging off a message or a composer, as a grid, a row of chips or a list.
Installation
pnpm dlx nachui add attachmentsAnatomy
Item puts the file in context, so Preview, Info and Remove read it themselves instead of taking the same object three times. An image with a url previews inline; anything else falls back to an icon you can swap.This is the read side of the story. For the picker and the drop zone see Prompt Input, and for a single file row with upload progress see Attachment.
Composition
Use the following composition to build an
Attachments:Variants
grid wraps cards and hides the remove button until hover, inline is a row of pills that fits above a composer, and list is one full width row per file where the remove button sits at the end.grid
inline
list
Data
data is a plain object, not an SDK type:formatSize and attachmentLabel are exported next to the component, so the same wording shows up wherever you list files.API Reference
Attachments
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'grid' | 'inline' | 'list' | 'grid' | Layout of the items |
className | string | - | Additional CSS classes |
Attachments.Item
| Prop | Type | Default | Description |
|---|---|---|---|
data | AttachmentData | - | The file this item describes |
onRemove | () => void | - | Called by Attachments.Remove |
className | string | - | Additional CSS classes |
Attachments.Preview
| Prop | Type | Default | Description |
|---|---|---|---|
fallbackIcon | ReactNode | file icon | Shown when there is no image preview |
className | string | - | Additional CSS classes |
Attachments.Info
| Prop | Type | Default | Description |
|---|---|---|---|
showMediaType | boolean | false | Adds the media type to the meta line |
className | string | - | Additional CSS classes |
Attachments.Remove
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | 'Remove' | Prefix of the accessible name |
className | string | - | Additional CSS classes |
Attachments.Empty
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.