# Thread URL: /docs/ui/thread The main chat container with messages, composer, and auto-scroll. A complete chat interface that combines message rendering, auto-scrolling, composer input, attachments, and conditional UI states. Fully customizable and composable. Anatomy \[#anatomy] The `Thread` component is built with the following primitives: ```tsx import { ThreadPrimitive, AuiIf } from "@assistant-ui/react"; s.thread.isEmpty}> {/* ThreadWelcome includes ThreadPrimitive.Suggestions */} {({ message }) => { if (message.role === "user") return ; return ; }} ``` Getting Started \[#getting-started] Add the component \[#add-the-component] This adds a `/components/assistant-ui/thread.tsx` file to your project, which you can adjust as needed. Use in your application \[#use-in-your-application] ```tsx title="/app/page.tsx" {1,6} import { Thread } from "@/components/assistant-ui/thread"; export default function Chat() { return (
); } ```
Examples \[#examples] Welcome Screen \[#welcome-screen] ```tsx s.thread.isEmpty}> ``` Viewport Spacer \[#viewport-spacer] ```tsx !s.thread.isEmpty}>
``` Conditional Send/Cancel Button \[#conditional-sendcancel-button] ```tsx !s.thread.isRunning}> Send s.thread.isRunning}> Cancel ``` Suggestions \[#suggestions] Display suggested prompts using the Suggestions API. See the [Suggestions guide](/docs/guides/suggestions) for detailed configuration. ```tsx import { SuggestionPrimitive, ThreadPrimitive } from "@assistant-ui/react"; // Configure suggestions in your runtime provider const aui = useAui({ suggestions: Suggestions(["What's the weather?", "Tell me a joke"]), }); // Display suggestions in your thread component {() => } // Custom suggestion item const SuggestionItem = () => ( ); ``` API Reference \[#api-reference] The following primitives are used within the Thread component and can be customized in your `/components/assistant-ui/thread.tsx` file. Root \[#root] Contains all parts of the thread. This primitive renders a `
` element unless `asChild` is set. Viewport \[#viewport] The scrollable area containing all messages. Automatically scrolls to the bottom as new messages are added. This primitive renders a `
` element unless `asChild` is set. Messages \[#messages] Renders all messages in the thread. This primitive renders a separate component for each message. ```tsx {({ message }) => { if (message.role === "user") return ; return ; }} ``` MessageByIndex \[#messagebyindex] Renders a single message at the specified index. ```tsx ``` Empty \[#empty] Renders children only when there are no messages in the thread. ScrollToBottom \[#scrolltobottom] A button to scroll the viewport to the bottom. Disabled when the viewport is already at the bottom. This primitive renders a `