# Thread URL: /docs/ui/thread The main chat container with messages, composer, and auto-scroll. *** title: Thread description: The main chat container with messages, composer, and auto-scroll. ------------------------------------------------------------------------------ import { ParametersTable } from "@/components/docs/tables/ParametersTable"; import { InstallCommand } from "@/components/docs/fumadocs/install/install-command"; import { ThreadSample } from "@/components/docs/samples/thread-sample"; A complete chat interface that combines message rendering, auto-scrolling, composer input, attachments, and conditional UI states. Fully customizable and composable. ## Anatomy The Thread component is built with the following primitives: ```tsx import { ThreadPrimitive, AssistantIf } from "@assistant-ui/react"; ``` ## Getting Started ### 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 ```tsx title="/app/page.tsx" {1,6} import { Thread } from "@/components/assistant-ui/thread"; export default function Chat() { return (
); } ```
## Examples ### Welcome Screen ```tsx thread.isEmpty}> ``` ### Viewport Spacer ```tsx !thread.isEmpty}>
``` ### Conditional Send/Cancel Button ```tsx !thread.isRunning}> Send thread.isRunning}> Cancel ``` ### Suggestions ```tsx ``` ## API Reference The following primitives are used within the Thread component and can be customized in your `/components/assistant-ui/thread.tsx` file. ### Root Contains all parts of the thread. This primitive renders a `
` element unless `asChild` is set. ### 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 Renders all messages in the thread. This primitive renders a separate component for each message. ```tsx ``` ### MessageByIndex Renders a single message at the specified index. ```tsx ``` ### Empty Renders children only when there are no messages in the thread. ### ScrollToBottom A button to scroll the viewport to the bottom. Disabled when the viewport is already at the bottom. This primitive renders a `