# Thinking Trace

> Collapsible reasoning steps with a live status for each.

```tsx
import { ThinkingTrace } from '@brand-studio/ui';

export default function ThinkingTraceDemo() {
  return (
    <div style={{ width: '100%', maxWidth: 480 }}>
      <ThinkingTrace
        defaultOpen
        steps={[
          { id: 'read', title: 'Read the order history', detail: '14 orders since March', status: 'done' },
          { id: 'compare', title: 'Compare roast preferences', detail: 'Mostly light, two medium', status: 'done' },
          { id: 'pick', title: 'Pick three new coffees', status: 'active' },
          { id: 'write', title: 'Write the recommendation', status: 'pending' },
        ]}
      />
    </div>
  );
}
```

## Installation

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, ThinkingTrace } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { ThinkingTrace } from '@brand-studio/ui';
```

```tsx
<ThinkingTrace
  steps={[
    { id: 'read', title: 'Read the order history', status: 'done' },
    { id: 'pick', title: 'Pick three coffees', status: 'active' },
  ]}
/>
```

## Examples

### Finished

When no step is active, the summary counts the steps and the trace starts closed.

```tsx
import { ThinkingTrace } from '@brand-studio/ui';

export default function ThinkingTraceFinished() {
  return (
    <div style={{ width: '100%', maxWidth: 480 }}>
      <ThinkingTrace
        steps={[
          { id: 'read', title: 'Read the order history', status: 'done' },
          { id: 'compare', title: 'Compare roast preferences', status: 'done' },
          { id: 'pick', title: 'Pick three new coffees', status: 'done' },
        ]}
      />
    </div>
  );
}
```

## Accessibility

- Built on `<details>`, so it opens with Enter or Space and works before JavaScript loads.
- Each step's status is spelled out for screen readers.

## API Reference

| Prop | Type | Default |
|---|---|---|
| `steps` | `TraceStep[]` | – |
| `title?` | `string` | – |
| `defaultOpen?` | `boolean` | `false` |
| `className?` | `string` | `''` |

Source: https://brandstudio.js.org/docs/components/thinking-trace/
