Composer
The user interface to add new messages or edit existing ones.
Dual Use! A Composer placed directly inside a Thread
will compose new
messages. A Composer placed inside a Message
will edit that message.
Anatomy
API Reference
Root
Containts all parts of the composer.
This primitive renders a <form>
element unless asChild
is set.
ComposerRootProps
asChild:
Change the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
Input
The text input field for the user to type a new message.
This primitive renders a <textarea>
element unless asChild
is set.
ComposerPrimitiveInputProps
asChild:
Change the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
Keyboard Shortcuts
Send
The button to send the message.
This primitive renders a <button>
element unless asChild
is set.
ComposerPrimitiveSendProps
asChild:
Change the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
Cancel
Sends a cancel action.
In edit composers, this action exits the edit mode.
In thread composers, this action stops the current run.
This primitive renders a <button>
element unless asChild
is set.
ComposerPrimitiveCancelProps
asChild:
Change the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
Attachments
Renders attachments. This primitive renders a separate component for each attachment.
ComposerPrimitiveAttachmentsProps
components?:
The component to render for each attachment.
ComposerPrimitiveAttachmentsProps['components']
Image?:
The component to render for each image attachment.
Document?:
The component to render for each document attachment.
File?:
The component to render for each file attachment.
Fallback?:
The component to render for each attachment type.
AddAttachment
Renders a button to add an attachment.
This primitive renders a <button>
element unless asChild
is set.
ComposerPrimitiveAddAttachmentProps
asChild:
Change the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
If
Renders children if a condition is met.
UseComposerIfProps
editing?:
Render children if the message is being edited.