import { Canvas, Controls, Meta, Title } from '@storybook/addon-docs/blocks';
import * as ChainOfThoughtStories from './ChainOfThought.stories';
<Meta of={ChainOfThoughtStories} name='Usage' />
<Title />
{/* check-docs-ignore: usage -- the designer removed the Usage section by hand */}
## Purpose
A collapsible list of the steps an agent took or plans to take. Use it to let people see an agent's work without putting it in their way. The summary line is always visible; the steps open on demand. It can open on its own while the agent is working (`expandWhenActive`) and collapse when done.
## TL;DR: Chain of Thought, Event Log or Timeline?
- **Chain of Thought:** an agent's reasoning under a reply, behind a summary line ("Thought for 17s") that opens on demand. No line, no rail.
- **Event Log:** events that happened or are happening, one line each (status icon, label, time). Always open, and the main content of a screen: a deploy history, an event log, an agent's run. Optional rail between the icons.
- **Timeline:** steps people read in order, often still ahead of them, with a heading and a paragraph each on a card. One line runs down the whole list: the stages of an application process.
Quick test:
1. Do the steps sit under a reply and need to stay out of the way? **Chain of Thought.**
2. Otherwise, does each entry have a status icon or a time at the end of the row? **Event Log.**
3. Otherwise, does each have a heading and a paragraph? **Timeline.**
A Chain of Thought is built from an Event Log and uses the same rows, and it can sit inside an Event Log as one entry in a log. Do not mix Event Log Items and Timeline in one list.
## The summary line
The summary is a Thinking State. For a finished run, put the whole phrase in `label`, duration included ("Thought for 4s"), and leave `showTimer` off. Use `showTimer` and `time` only for a live run: while the agent works, show a label such as "Working..." and update `time` as it ticks, or leave the timer off. A ticking value is hidden from screen readers.
## Accessibility
- The summary is a native `summary` inside `details`, so it is a button-like control that Enter and Space toggle, and it has a visible focus ring. The browser exposes whether the list is expanded or collapsed.
- The summary holds a Thinking State, which is a live region (`role="status"`). While the agent is active, keep the label stable and change it only when the state changes, so the summary is not announced again on every update. Do not repeat the same text elsewhere, so it is not announced twice.
- Pass a finished duration inside `label`. A separate timer element would be read apart from its label.
- The steps are a list (`EventLog`), so a screen reader announces how many there are. Each step's status is visually hidden text, and the active spinner has its own label. Those strings are translatable props on the step.
- The shimmer and the icon pulse stop under `prefers-reduced-motion`.
- Not yet tested with a screen reader, and the a11y panel has not been run on these stories.
## Implementation
See the table below for the available props. The other stories show every variant and state.
- `iconName` — Which icon to render before the summary label.
- `isActive` — Is the agent still working? Shimmers the summary label and pulses its icon. Leave `false` for a finished record.
- `isOpen` — Initial open state.
- `size` — Size of the whole block: `s` is a 14px summary over 12px rows; `m` is a 16px summary over 14px rows.
<hr />
<Canvas of={ChainOfThoughtStories.Steps} />
<Controls of={ChainOfThoughtStories.Steps} />
Chain of Thought
A collapsible list.
Net-new componentOpen in Storybook