An ordered list of agent steps with status marks, shown inside Reasoning.
Use ChainOfThought to list an agent's steps, such as file reads, tool calls, and edits, inside Reasoning.
import {ChainOfThought, Reasoning} from "@heroui-pro/react";
<Reasoning>
<Reasoning.Trigger />
<Reasoning.Content>
<ChainOfThought>
<ChainOfThought.Step status="complete">
<ChainOfThought.StepTitle>Searched the web</ChainOfThought.StepTitle>
<ChainOfThought.StepDescription>Found 4 sources</ChainOfThought.StepDescription> {/* Optional */}
</ChainOfThought.Step>
</ChainOfThought>
</Reasoning.Content>
</Reasoning>;Give each step a status of complete, active, pending, or error; a step without one shows a neutral dot.
ChainOfThought takes its status from the enclosing Reasoning. When Reasoning is stopped or error, the active step shows as interrupted and pending steps are hidden.
import type {ChainOfThoughtStepStatus, ReasoningStatus} from "@heroui-pro/react";
import {getToolName, isToolUIPart, type ToolUIPart} from "ai";
const toStepStatus = (state: ToolUIPart["state"]): ChainOfThoughtStepStatus | undefined => {
if (state === "output-available") return "complete";
if (state === "output-error") return "error";
if (state === "output-denied") return undefined;
if (state === "approval-requested") return "pending";
return "active"; // input-streaming, input-available, approval-responded
};
const tools = message.parts.filter(isToolUIPart);
const isWorking = tools.some((tool) => toStepStatus(tool.state) === "active");
const status: ReasoningStatus = toStatus(message, isWorking ? "streaming" : "done");
<Reasoning status={status}>
<Reasoning.Trigger />
<Reasoning.Content>
<ChainOfThought>
{tools.map((tool) => (
<ChainOfThought.Step key={tool.toolCallId} status={toStepStatus(tool.state)}>
<ChainOfThought.StepTitle>{getToolName(tool)}</ChainOfThought.StepTitle>
{tool.state === "output-error" ? (
<ChainOfThought.StepDescription>{tool.errorText}</ChainOfThought.StepDescription>
) : null}
</ChainOfThought.Step>
))}
</ChainOfThought>
</Reasoning.Content>
</Reasoning>;Each tool part becomes a step, and its state maps to the step status. A step waiting for approval is pending, so the block stops reading as working. A denied step has no status; render Denied as its ChainOfThought.StepDescription, the same way as errorText. The block status comes from your message: toStatus is the per-message mapping from Reasoning with AI SDK. Render each run of consecutive tool parts as its own block, and give each phase its own Reasoning: thinking as Reasoning.Text, tool work as a ChainOfThought. collapseDelay={Infinity} keeps finished blocks open.
Saved traces need no status. Every block reads as complete, and steps keep the status you saved.
<Reasoning>
<Reasoning.Trigger>
<Reasoning.Label>Explored 3 files</Reasoning.Label>
<Reasoning.Indicator />
</Reasoning.Trigger>
<Reasoning.Content>
<ChainOfThought>
{steps.map((step) => (
<ChainOfThought.Step key={step.id} status="complete">
<ChainOfThought.StepTitle>{step.title}</ChainOfThought.StepTitle>
</ChainOfThought.Step>
))}
</ChainOfThought>
</Reasoning.Content>
</Reasoning>To replace the default "Thinking" and "Thought for 1m 12s" for an agent run, pass a function to Reasoning.Label.
<Reasoning duration={duration} status={status}>
<Reasoning.Trigger>
<Reasoning.Loader />
<Reasoning.Label>
{({duration, isStreaming, status}) => {
if (isStreaming) return <TextShimmer>Working</TextShimmer>;
if (status === "error") return "Couldn't finish";
if (status === "stopped" && !duration) return "Stopped working";
if (status === "stopped") return <>Stopped after <Reasoning.Duration /></>;
if (!duration) return "Worked for a few seconds";
return <>Worked for <Reasoning.Duration /></>;
}}
</Reasoning.Label>
<Reasoning.Indicator />
</Reasoning.Trigger>
<Reasoning.Content>
<ChainOfThought>{steps}</ChainOfThought>
</Reasoning.Content>
</Reasoning>Pass a node to indicator to replace the check and keep its disc, or a function of {status} to draw the whole mark for every status.
import {Magnifier} from "@gravity-ui/icons";
<ChainOfThought>
<ChainOfThought.Step indicator={<Magnifier />} status="complete">
<ChainOfThought.StepTitle>Searched the release notes</ChainOfThought.StepTitle>
</ChainOfThought.Step>
</ChainOfThought>;HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The Chain Of Thought component uses these CSS classes. The trigger and panel classes belong to Reasoning; see Reasoning CSS classes.
.chain-of-thought: Ordered step list.chain-of-thought__step: One step.chain-of-thought__step-indicator: Lane with the mark and the line below it.chain-of-thought__step-body: Step content column.chain-of-thought__step-status: Visually hidden status text.chain-of-thought__step-title: Step title.chain-of-thought__step-description: Step descriptionThe chain-of-thought__step-mark, chain-of-thought__step-glyph*, chain-of-thought__step-check, and chain-of-thought__step-cross classes are internal; use indicator to change the mark.
[data-status="streaming|complete|stopped|error"] on .chain-of-thought: Run status[data-status="complete|active|pending|error|interrupted"] on .chain-of-thought__step and .chain-of-thought__step-indicator: Step status; absent for a step without a status--chain-of-thought-mark-size: Mark lane and active disc (default: calc(var(--spacing) * 5))--chain-of-thought-active-ring-inset: Gap between the active disc and its ring (default: var(--spacing))--chain-of-thought-line: Solid line below a settled step (default: muted at 26%)--chain-of-thought-line-pending: Dashed line below an active or pending step (default: muted at 45%)--chain-of-thought-duration: Mark crossfade, line color, and title color changes (default: 150ms)--chain-of-thought-ease: Easing for those transitions (default: var(--ease-out-quint))Renders an ol, which CSS hides while it has no steps. Supports native ol props. The deprecated beta root also takes the beta Disclosure props, such as isDisabled, id, and a function className; see Deprecated API.
| Prop | Type | Default | Description |
|---|---|---|---|
status | "streaming" | "complete" | "stopped" | "error" | - | Run status. Defaults to the enclosing Reasoning status, or "complete" outside one |
statusLabel | (renderProps: ChainOfThoughtStepStatusLabelRenderProps) => ReactNode | - | Visually hidden status text read before each step. An empty result keeps the built-in text |
ChainOfThoughtStepStatusLabelRenderProps is {status: ChainOfThoughtStepDisplayStatus; defaultLabel: string}. ChainOfThoughtStepDisplayStatus is "complete" | "active" | "pending" | "error" | "interrupted".
Renders an li with the status mark, then its children in order, so any content, such as a ChatSources.List, can follow the title. The active step gets aria-current="step", and its ring is a Loader, so it follows reduced motion. Supports native li props.
| Prop | Type | Default | Description |
|---|---|---|---|
status | "complete" | "active" | "pending" | "error" | - | Step status. Without it, the step shows a neutral dot and has no hidden status text |
indicator | ReactNode | ((renderProps: ChainOfThoughtStepIndicatorRenderProps) => ReactNode) | - | A node replaces the complete check and keeps its disc; a function draws the whole mark and also receives interrupted |
ChainOfThoughtStepIndicatorRenderProps is {status?: ChainOfThoughtStepDisplayStatus}; status is undefined for a step without a status.
Step text. Support native div props.
| Default text | Where | Override |
|---|---|---|
| "Completed" | Hidden status text of a complete step | statusLabel on ChainOfThought |
| "In progress" | Hidden status text of an active step | statusLabel on ChainOfThought |
| "Not started" | Hidden status text of a pending step | statusLabel on ChainOfThought |
| "Failed" | Hidden status text of an error step | statusLabel on ChainOfThought |
| "Didn't finish" | Hidden status text of an interrupted step | statusLabel on ChainOfThought |
statusLabel receives {status, defaultLabel} and returns text or a node. Return defaultLabel for statuses you don't handle, since later releases may add new ones.
import type {
ChainOfThoughtStepDisplayStatus,
ChainOfThoughtStepStatusLabelRenderProps,
} from "@heroui-pro/react";
const stepStatusLabels: Partial<Record<ChainOfThoughtStepDisplayStatus, string>> = {
active: "Running",
complete: "Done",
error: "Error",
interrupted: "Cancelled",
pending: "Queued",
};
const statusLabel = ({defaultLabel, status}: ChainOfThoughtStepStatusLabelRenderProps) =>
stepStatusLabels[status] ?? defaultLabel;
<ChainOfThought statusLabel={statusLabel}>{steps}</ChainOfThought>;| API | Use instead |
|---|---|
ChainOfThought isStreaming | status="streaming" on Reasoning |
ChainOfThought defaultExpanded, isDisabled, isExpanded, onExpandedChange | The same props on Reasoning |
ChainOfThought.Trigger, ChainOfThought.Content | Reasoning.Trigger, Reasoning.Content |
ChainOfThought.Steps | ChainOfThought itself; render ChainOfThought.Step directly inside it |
ChainOfThought.Step label | A ChainOfThought.StepTitle child |
A deprecated prop, or a direct ChainOfThought.Trigger, ChainOfThought.Content, or ChainOfThought.Steps child, renders a Reasoning in place of the list, as in beta. The root's other beta Disclosure props go to that Reasoning, and its status and statusLabel reach the step lists inside unless a list sets its own. See v1.0.0 for the full migration.
active at a time, since it carries aria-current="step".ChainOfThought adds no live region and never sets aria-busy. Inside Reasoning, the body has aria-busy while streaming.Resources