Attachment
Displays a file or image attachment with media, metadata, upload state, and actions. For chat composers, threads, and upload lists.
Installation#
pnpm dlx shadcn@latest add @davinciui/attachmentUsage#
Attachment is presentational: it renders upload state but never uploads. Own file selection, transport, and removal in the host, and reflect progress through state and the description text.
Attachment ├── AttachmentMedia ├── AttachmentContent │ ├── AttachmentTitle │ └── AttachmentDescription ├── AttachmentActions │ └── AttachmentAction └── AttachmentTrigger AttachmentGroup ├── Attachment └── Attachment
Composition#
Use the following composition to build a Attachment:
AttachmentGroup
└── Attachment
├── AttachmentMedia
├── AttachmentContent
│ ├── AttachmentTitle
│ └── AttachmentDescription
└── AttachmentActions
├── AttachmentAction
└── AttachmentTriggerAPI Reference#
| Prop | Type | Default |
|---|---|---|
stateUpload lifecycle state. Busy states shimmer the title. | "idle" | "uploading" | "processing" | "error" | "done" | "done" |
sizeAttachment size. | "default" | "sm" | "xs" | "default" |
orientationMedia beside or above the content. | "horizontal" | "vertical" | "horizontal" |
variantMedia slot content (AttachmentMedia). | "icon" | "image" | "icon" |
renderRender the trigger as a link or custom element (AttachmentTrigger). | ReactElement | — |
aria-labelRequired on icon-only actions and textless triggers. | string | — |
classNameAdditional classes on any part. | string | — |
Accessibility#
AttachmentAction is a native button with a focus-visible ring, and AttachmentTrigger is a button or link needing aria-label when icon-only. The scrollable AttachmentGroup is not keyboard focusable by default; add tabIndex, role='group', and a label.
Motion#
The card transitions border colors over 200ms, and uploading or processing states apply animate-pulse to the title. The pulse has no motion-reduce guard, so reduced-motion preference is not detected or honored.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

