Shadcn Attachment
React attachment for files in a composer or thread. Built with TypeScript and Tailwind CSS for Next.js using Base UI — upload states, sizes, and a full-card trigger.
An attachment is a file card: media, name, size, and actions. Use it in a composer, a message thread, or an upload list. It does not upload — you map your own machine onto state.
Usage
import {
Attachment,
AttachmentAction,
AttachmentActions,
AttachmentContent,
AttachmentDescription,
AttachmentMedia,
AttachmentTitle,
} from "@/components/ui/attachment"<Attachment>
<AttachmentMedia>
<FileTextIcon />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>kit-readme.pdf</AttachmentTitle>
<AttachmentDescription>PDF · 2.4 MB</AttachmentDescription>
</AttachmentContent>
<AttachmentActions>
<AttachmentAction aria-label="Remove kit-readme.pdf">
<XIcon />
</AttachmentAction>
</AttachmentActions>
</Attachment>state is idle, uploading, processing, error, or done. Idle is the dashed drop target.
Composition
AttachmentGroup is a scroll row of Attachments.
Image
variant="image" on AttachmentMedia plus an <img>. orientation="vertical" stacks the photo above the name.
States
uploading and processing shimmer the title. error is the red treatment — keep the reason in the description.
Sizes
default in a composer, sm in a thread, xs in a dense list.
Group
AttachmentGroup is a horizontal snap-scroll with an edge fade. Ten files stay one row tall.
Trigger
AttachmentTrigger fills the card behind the actions. Wrap it in a Dialog trigger or a render={<a />} link.
API
Prop
Type
AttachmentMedia
Prop
Type
AttachmentTrigger
Prop
Type
AttachmentAction is a Button. Default size is icon-xs.
Notes
Name every icon button
aria-label="Remove kit-readme.pdf" — not a bare X. Color is not the error message; put the reason in AttachmentDescription.
This component does not upload. You own fetch, XHR, or the signed URL.
With other components
Remove, retry, cancel
DialogFull-size preview
SpinnerInside the media slot
ProgressByte-level upload
InputThe file picker
MessageFiles in a thread
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Aspect Ratio
React aspect ratio for images and video embeds. Built with TypeScript and Tailwind CSS for Next.js using Base UI — lock 16/9, 1/1, or any width over height.
Avatar
React avatar for profile photos, comments, and team lists. Built with TypeScript and Tailwind CSS for Next.js using Base UI — image, fallback, badge, and groups.