Chain of Thought
A timeline of reasoning and tool-call steps.
Usage
Basic
Loading demo...
Best Practices
- Key steps by a stable
id, not an array index. - Keep at most one
activestep; auto-scroll follows only one. - Move a finished step from
activetodoneorerror, or its spinner stays. - Write tool titles as call signatures (
read_file(src/main.ts)), not bare tool names. - For custom step rendering, compose
TxReasoningDisclosureandTxToolCallCard.
API Reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
steps | AiChainStep[] | — | The steps, required. AiChainStep is { id, kind: 'thinking' | 'tool', title, body?, status: 'active' | 'done' | 'error', durationMs? }. |
streaming | boolean | false | Output is still arriving; with an active step, the header shows a thinking orb. |
defaultOpen | boolean | true | Open state while not streaming. |
label | string | 'Chain of thought' | Header label; override it on non-English surfaces. |
userOpen | boolean | — | Host-held open state that overrides everything; feed toggle back in so it survives remounts. |
Events
| Name | Payload | Description |
|---|---|---|
toggle | (open: boolean) | Fires on a header click with the resulting open state. |
Overview
- Open state:
userOpenwins, then a user click; otherwise it follows active steps while streaming anddefaultOpenwhen not. - When any step's
bodygrows, the active step's body scrolls to its end. - A
donestep withdurationMsshows its duration after the title (· 3.2s; whole seconds from 10s). - The header count is
steps.length, hidden for a single step. - The header is a native
<button>witharia-expandedandaria-controls; steps are an<ol>.