A collapsible block that shows the model's thinking and collapses when it is done.
Set status="streaming" while the model thinks, and pass duration as text, such as "3s".
import {Reasoning} from "@heroui-pro/react";
<Reasoning>
<Reasoning.Trigger>
<Reasoning.Loader /> {/* Optional */}
<Reasoning.Label />
<Reasoning.Indicator />
</Reasoning.Trigger>
<Reasoning.Content>
<Reasoning.Text>{/* ... */}</Reasoning.Text>
</Reasoning.Content>
</Reasoning>;Set status="stopped" when the run is stopped or cut off, and status="error" when it fails. Both keep the trace open or collapsed as it was, even if complete follows.
To list an agent's steps in the trace, place a Chain Of Thought inside Reasoning.Content. It takes the same status.
Join a run of reasoning parts into one Reasoning, and read the state of the last part.
A stop or an error leaves the part at streaming, so record each message's outcome in onFinish, which runs in both cases. Send duration as message metadata from your server, and map a server cutoff, such as a finishReason of "length" or "content-filter", to "stopped". Save the outcome in message.metadata to keep it after a reload.
Custom backend. With your own stream, keep one status per block and set it from your events.
const [status, setStatus] = useState<ReasoningStatus>("streaming");
useEffect(() => {
const events = new EventSource(url);
// Closing also stops EventSource from reconnecting after an error.
const end = (next: ReasoningStatus) => {
events.close();
setStatus(next);
};
events.addEventListener("thinking_delta", (event) => setText((text) => text + event.data));
events.addEventListener("thinking_end", () => end("complete"));
events.addEventListener("aborted", () => end("stopped"));
events.addEventListener("error", () => end("error"));
return () => events.close();
}, [url]);Saved messages need no status. The default, complete, reads "Thought for 9s" and never collapses on its own.
<Reasoning duration="9s">
<Reasoning.Trigger />
<Reasoning.Content>
<Reasoning.Text>{text}</Reasoning.Text>
</Reasoning.Content>
</Reasoning>Use Reasoning.Loader to pick another Loader variant, or pass your own indicator, such as a Spinner, as its children.
Reasoning.Label already shows the status, so don't add Loader.Label or label here.
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The Reasoning component uses these CSS classes:
.reasoning: Root disclosure.reasoning__heading: Heading around the trigger.reasoning__trigger: Trigger button.reasoning__loader: Loader slot.reasoning__label: Trigger label.reasoning__duration: Emphasized duration.reasoning__indicator: Chevron.reasoning__content: Collapsible panel.reasoning__body: Content wrapper.reasoning__text: Thinking text[data-hovered="true"] and [data-pressed="true"] on .reasoning__trigger (fill and foreground text)[data-focus-visible="true"] on .reasoning__trigger (focus ring)[data-status="streaming|complete|stopped|error"] on .reasoning and .reasoning__label: Run status[data-streaming] on .reasoning and .reasoning__label: Thinking is in progress[data-exiting] on .reasoning__loader: Loader is fading outThe panel and chevron use the HeroUI Disclosure timing. Under prefers-reduced-motion: reduce, the panel, chevron, trigger fill, loader, and label change without a transition, like Disclosure.
--reasoning-duration: Loader exit, label fade, and trigger colors (default: 150ms)--reasoning-ease: Easing for those transitions (default: var(--ease-out-quint))--reasoning-trigger-inset: Trigger padding, pulled back so the text lines up with the content (default: calc(var(--spacing) * 2))--reasoning-trigger-gap: Gap between the loader, label, and chevron (default: calc(var(--spacing) * 2))Extends HeroUI Disclosure props. The root fills its container and has no background.
| Prop | Type | Default | Description |
|---|---|---|---|
status | "streaming" | "complete" | "stopped" | "error" | "complete" | Run status of this block |
duration | string | - | Formatted thinking time, such as "9s", shown once complete or stopped |
autoExpand | boolean | true | Opens the trace when the first content streams in |
collapseDelay | number | 1000 | Milliseconds before the automatic collapse. Infinity never collapses |
defaultExpanded | boolean | false | Initial state when uncontrolled |
isExpanded | boolean | - | Controlled expanded state |
onExpandedChange | (isExpanded: boolean) => void | - | Called when the expanded state changes, including the automatic open and collapse |
children | ReactNode | - | Reasoning.Trigger and Reasoning.Content |
The trace opens on the first text and collapses collapseDelay after complete, unless the user toggled it. The automatic collapse waits until focus leaves the trace. When controlled, the automatic open and collapse only call onExpandedChange. An uncontrolled root that mounts mid-stream with content starts open without calling it. The automatic open waits for visible content in Reasoning.Content. With autoExpand={false}, the trace stays as it is while streaming, but a trace that is open when the run completes still collapses after collapseDelay unless the user toggled it.
Extends HeroUI Disclosure.Trigger props. Renders the loader, label, and chevron by default; children replace them. The trigger is a button inside a heading.
| Prop | Type | Default | Description |
|---|---|---|---|
headingLevel | number | 3 | Level of the heading around the trigger |
Shown while streaming, then fades out. Extends Loader props.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "ring" | "classic" | "dots" | "pulse" | "scan" | "grid" | "shuffle" | "wave" | "sparkle" | "atom" | "morph" | "helix" | "twist" | "infinity" | "grid" | Indicator style |
size | "sm" | "md" | "lg" | "sm" | Indicator size: 16, 20 or 24px |
children | ReactNode | - | Loader.Indicator or a custom indicator |
Supports native span props.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | ((renderProps: ReasoningLabelRenderProps) => ReactNode) | - | Replaces the default text. A function can return defaultChildren |
ReasoningLabelRenderProps is {status, isStreaming, duration, defaultChildren}. The default texts are listed under Localization.
Renders duration, or nothing when it is empty. Children replace the text. Supports native span props.
Extends HeroUI Disclosure.Indicator props.
Extends HeroUI Disclosure.Content props. A collapsed panel uses hidden="until-found", so find in page can open it. To cap a long trace, add max-h-96 overflow-y-auto.
Thinking text that keeps its line breaks. Renders nothing while empty, and works outside a Reasoning. Supports native div props.
| Default text | Where | Override |
|---|---|---|
| "Thinking" | Reasoning.Label while streaming | Function child of Reasoning.Label |
| "Thought for 9s" | Reasoning.Label when complete with duration | Function child of Reasoning.Label |
| "Thought for a few seconds" | Reasoning.Label when complete without duration | Function child of Reasoning.Label |
| "Stopped after 5s" | Reasoning.Label when stopped with duration | Function child of Reasoning.Label |
| "Stopped thinking" | Reasoning.Label when stopped without duration | Function child of Reasoning.Label |
| "Couldn't finish thinking" | Reasoning.Label when error | Function child of Reasoning.Label |
Return defaultChildren for statuses you don't handle, and render Reasoning.Duration where the time belongs. duration is shown as given, so format it for the user's locale yourself, for example with Intl.DurationFormat.
<Reasoning duration={duration} status={status}>
<Reasoning.Trigger>
<Reasoning.Loader />
<Reasoning.Label>
{({defaultChildren, duration, status}) =>
status === "complete" && duration ? (
<>
Reasoned for <Reasoning.Duration />
</>
) : (
defaultChildren
)
}
</Reasoning.Label>
<Reasoning.Indicator />
</Reasoning.Trigger>
<Reasoning.Content>
<Reasoning.Text>{text}</Reasoning.Text>
</Reasoning.Content>
</Reasoning>aria-busy while streaming. Reasoning adds no live region, since the chat log announces the answer, so place it inside a Chat Conversation.Resources