Components for displaying and managing file attachments in messages and composer.
Buttons to interact with attachments.
Dual Use! Attachments can appear in both messages and composers.
Anatomy
import { AttachmentPrimitive } from "@assistant-ui/react";
const MyMessageAttachment = () => (
<AttachmentPrimitive.Root>
<AttachmentPrimitive.unstable_Thumb />
<AttachmentPrimitive.Name />
</AttachmentPrimitive.Root>
);
const MyComposerAttachment = () => (
<AttachmentPrimitive.Root>
<AttachmentPrimitive.unstable_Thumb />
<AttachmentPrimitive.Name />
<AttachmentPrimitive.Remove />
</AttachmentPrimitive.Root>
);API Reference
Root
Contains all parts of the attachment.
This primitive renders a <div> element unless asChild is set. Accepts all standard HTML div element props.
AttachmentPrimitiveRootPropsasChild: boolean= falseChange the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
...props?: HTMLAttributes<HTMLDivElement>All standard div element props are forwarded to the underlying element.
unstable_Thumb
The thumbnail of the attachment.
This primitive renders a <div> element unless asChild is set. Accepts all standard HTML div element props.
AttachmentPrimitiveThumbPropsasChild: boolean= falseChange the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
...props?: HTMLAttributes<HTMLDivElement>All standard div element props are forwarded to the underlying element.
Name
The name of the attachment.
This primitive renders a text node with the attachment's file name. It accepts no props.
AttachmentPrimitiveNamePropsRemove
Removes the attachment.
This primitive renders a <button> element unless asChild is set.
AttachmentPrimitiveRemovePropsasChild: boolean= falseChange the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.