Skip to content
WunderUI

Chain of Thought

Pro

A folded list of the steps an agent took, shown above or beside its answer.

Playground

Opened Q3-report.pdf.
Read the revenue dashboard.
Compared Q3 with Q2: revenue, new customers and churn.

Installation

Chain of Thought comes with WunderUI Core and Pro, in the package from your plan. See the plans.

Then import what you need:

tsx
import { ChainOfThought, ChainOfThoughtStatus } from "@wunderui/react"

Then use it:

tsx
import { ChainOfThought } from "@wunderui/react"

export function Reasoning({ running }: { running: boolean }) {
  return (
    <ChainOfThought
      status={running ? "running" : "completed"}
      steps={[
        "Opened Q3-report.pdf.",
        "Read the revenue dashboard.",
        "Wrote the summary.",
      ]}
    />
  )
}

Expected result: You see a bordered row with a sparkles icon and Thought for a few seconds. It starts closed, so press it to show three steps, and while running the text reads Thinking.

When to use

Use Chain of Thought for

  • The steps an agent took, folded under its answer in a chat
  • A live run whose steps arrive one by one and can be folded away
  • A short process summary a person may want to check

Use something else for

  • Chat Tool for one tool call with its status and result
  • Agent Plan for the steps an agent plans to take, before it takes them
  • Collapsible for any other show-more panel that is not a list of steps

Content

Each step is one short line of text. Long lines wrap, and the panel is as tall as its steps, with no maximum height and no scrolling.

Opened Q3-report.pdf.
Read the revenue dashboard.
Compared Q3 with Q2: revenue, new customers and churn.

Status

The status sets the header: Thinking… with a loader while running, Thought for a few seconds when done, Thinking failed on a red card, Thinking stopped when interrupted.

Opened Q3-report.pdf.
Read the revenue dashboard.

Placement

The list is closed by default so the answer comes first. In a chat it sits above the answer, and people open it when the process matters.

Opened Q3-report.pdf.
Read the revenue dashboard.
Compared Q3 with Q2: revenue, new customers and churn.

Newer props

The label and the steps take the text size of the container, so a text-sm class on the root sets both. Give the box a width when it sits in a narrow column.

Inherited size and a fixed width

Read the three failing tests
Traced the rounding to the tax helper
Checked the fix against the fixtures

Keyboard interactions

The toggle is a native button, so the browser handles focus and activation. The steps are text and take no focus.

TaborShiftTab
Moves focus to the toggle and away from it. Focus shows as an indigo border with a 2 px ring.
EnterorSpace
Opens or closes the steps. follows.

A closed panel is inert, so nothing inside it can be reached or read out. There is no arrow-key navigation, and a status change does not move focus.

Behavior and motion

What the list does with its state, its content, assistive technology and motion.

Open state
The open state is internal and the default is read once, when the component mounts. To start a new run open, give the component a new key.
Header and status
Without a status the label and icon are fixed. With one (running, completed, failed or interrupted) both follow it and the box is busy only while running, and your own label replaces the text.
Steps
Steps are an array of strings, rendered as text lines with a bullet. They are plain divs, so a screen reader announces no list, and entries are keyed by position, so append and do not reorder.
Growing list
Adding a step while the panel is open makes it taller at once, without a transition. The panel stays mounted when closed, so steps that arrive while it is folded are there when it opens.
Live region
The component has no live region, so a status change is not announced by itself. Add a status line that names the current step and the outcome, or keep the list in the chat log.
Toggle semantics
The toggle is a button that reports whether it is expanded, named by its label. While closed, the panel is inert: nothing in it takes focus or is read out.
Motion
The chevron turns and the running loader spins. The panel opens with the same smooth height transition the Collapsible uses.
Reduced motion
With reduced motion the panel opens at once, the chevron turns at once and the loader stands still. The header text still says Thinking.

Anatomy

The figure marks the open list in its default state, without a status. The toggle is the first child of the box.

Opened Q3-report.pdf.
Read the revenue dashboard.
Compared Q3 with Q2: revenue, new customers and churn.
  • data-slot="chain-of-thought"

    The bordered box that holds the toggle and the steps. It keeps its open state itself, is marked busy while running and turns red when failed.

  • A native button that fills the first row and reports whether the panel is expanded. Its name is the label, Thought for a few seconds by default, or the status text or your own label.

  • A 14 px decorative icon before the label: Sparkles by default and when completed, a turning loader while running, a warning triangle when failed, a ban when interrupted.

  • The header text. Without a status it is Thought for a few seconds, and with one it reads Thinking, Thought for a few seconds, Thinking failed or Thinking stopped, unless you pass your own.

  • Points down when closed and turns 180 degrees when open.

  • The panel under the toggle, with a top border and 16 px padding. It stays mounted, grows and shrinks smoothly, and is inert while closed.

  • One entry of the steps: a small bullet and a line of text. It is a plain div, not a list item, and it wraps when long.

Best practices

  • Do

    Show what the agent did, in short past-tense lines such as Opened Q3-report.pdf, not invented reasoning. People read the list to check the work.

  • Do

    Keep it closed, the default, so the answer comes first. Open it by default only where the steps are the content, for example while a run is live.

  • Do

    Set the status so the header says where the run is, and announce it elsewhere too, with a status line or the chat log. The component announces nothing.

  • Do

    Keep one thought per entry and write plain text. Entries render as text, so markup and links show as characters.

  • Do

    Once the run is completed, pass a measured time as the label, like Thought for 12 seconds. The default text is a placeholder for when you have no time.

  • Don’t

    Don't use failed for a step that only returned an empty result. It is for a run that did not finish, and the cause and next step belong in a message outside the list.

  • Don’t

    Don't hide a failure in the list. A failed step needs a visible message with the step and the cause, outside the folded panel.

  • Don’t

    Don't put required information or the only action in a closed list. What people must read or do belongs outside it.

API reference

One table. ChainOfThought is a plain component and wraps no primitive, so the table lists every prop.

The bordered box that holds the toggle and the steps. It keeps its open state itself, is marked busy while running and turns red when failed.

PropTypeDefaultDescription
steps requiredstring[]—The steps, one short line of text each, in order. They render as text, so markup in a string shows as characters. Append to the end while a run is live; entries are keyed by position.
status"running" | "failed" | "completed" | "interrupted"—Where the run is: , , or . It changes the header text and icon, sets while and turns the box red when . Without it the header keeps the fixed .
labelReactNode—Replaces the header text of any status, for example . A node is allowed; keep it short, it is the name of the toggle.
defaultOpenbooleanfalseWhether the list starts open. It is read once when the component mounts; a later change has no effect. Give the component a new to start it open or closed again.
classNamestring—Extra classes for the outer box, for example when it sits in a flex column that aligns its children to the start.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("chain-of-thought")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.