Thread
A conversation between a user and an assistant.
Anatomy
API Reference
Root
Containts all parts of the thread.
This primitive renders a <div>
element unless asChild
is set.
ThreadPrimitiveRootProps
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.
Viewport
The scrollable area containing all messages. Anchors scroll to the bottom as new messages are added.
This primitive renders a <div>
element unless asChild
is set.
ThreadPrimitiveViewportProps
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.
autoScroll:
Whether to automatically scroll to the bottom of the viewport when new messages are added while the viewport is was previously scrolled to the bottom.
Messages
Renders all messages. This primitive renders a separate component for each message.
ThreadPrimitiveMessagesProps
components?:
The component to render for each message.
MessageComponents
Message?:
The component to render for each message.
UserMessage?:
The component to render for user messages.
EditComposer?:
The component to render for user messages that are being edited.
AssistantMessage?:
The component to render for assistant messages.
Empty
Renders children only when there are no messages.
ScrollToBottom
A button to scroll the viewport to the bottom. Disabled when the viewport is already at bottom.
This primitive renders a <button>
element unless asChild
is set.
ThreadPrimitiveScrollToBottomProps
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.
ThreadPrimitive.Suggestion
Shows a suggestion to the user. When the user clicks on the suggestion, the composer's value is set to the suggestion's prompt.
This primitive renders a <button>
element unless asChild
is set.
If
Renders children if a condition is met.
ThreadPrimitiveIfProps
empty?:
Render children if the thread is empty.
running?:
Render children if the thread is running.