# ChainOfThought URL: /docs/primitives/chain-of-thought Collapsible accordion for grouping reasoning steps and tool calls. The ChainOfThought primitive groups consecutive reasoning and tool-call parts into a collapsible accordion. Reasoning models emit reasoning tokens and tool calls before producing a final answer. This primitive lets you collapse those intermediate steps behind a "Thinking" toggle. Grouped Chain of Thought currently plugs into `MessagePrimitive.Parts` via `components.ChainOfThought`. If you're wiring grouped CoT, use that API. ```tsx import { AuiIf, ChainOfThoughtPrimitive, MessagePrimitive, } from "@assistant-ui/react"; function AssistantMessage() { return ( {({ part }) => { if (part.type === "text") return ; return null; }} ); } function ChainOfThought() { return ( Thinking !s.chainOfThought.collapsed}> (

{text}

), tools: { Fallback: ({ toolName, status }) => (
{toolName} {status.type === "running" ? "running..." : "done"}
), }, }} />
); } ```
Quick Start \[#quick-start] Render your normal message parts with `MessagePrimitive.Parts`, then place a `ChainOfThought` component alongside them inside the same `MessagePrimitive.Root`: ```tsx import { ChainOfThoughtPrimitive, MessagePrimitive, } from "@assistant-ui/react"; {({ part }) => { if (part.type === "text") return ; return null; }} function MyChainOfThought() { return ( Thinking ); } ``` `Root` renders a `
`, `AccordionTrigger` renders a `