# Thinking

What an agent is doing while it works, with the steps behind it.

An agent's trace while it works: a shimmering label that expands to the steps behind it. Four variants: steps (check / spinner rows), reasoning (prose), search (query + sources read), coding (pressable tool rows). A sparkle and a shimmering label while working that settles into a 'Thought for 4 seconds' header, over a hairline rail (the header and trace are a collapsible) that grows as rows arrive. Fully controlled: the host owns working, expanded and the rows, so it maps directly onto real agent events.

Kind: block · Category: Agent · Status: beta · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add thinking-state
```

It writes the folder `thinking-state/` into the project's ui folder (`index.ts`, `thinking-state.tsx`, `ThinkingState.vue`, `ThinkingState.svelte`, `thinking-state.recipe.ts`), and what it is built from: [Collapsible](/components/collapsible.md), [Shimmer](/components/shimmer.md), [Spinner](/components/spinner.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { ThinkingState } from "@/components/ui/thinking-state";
```

```vue
import { ThinkingState } from "@/components/ui/thinking-state";
```

```svelte
import { ThinkingState } from "$lib/components/ui/thinking-state";
```

## Parts

In the DOM the root carries `data-slot="thinking-state"` and each part `data-slot="thinking-state-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `thinking-state` |  | data-variant, data-state=working\|done; data-ready once mounted (arms the status transitions) |
| `disclosure` | `div` | `thinking-state-disclosure` |  | A collapsible (variant inline, caret="start"): the trigger, its caret first (collapsible-caret, right turning down; before the sparkle and the label, so a label that changes length moves nothing) and the trace region (collapsible-content > collapsible-body, which holds the rail). Its engine sets aria-expanded, aria-controls and data-state, hides the closed trace (out of the tab order) and toggles instantly from the keyboard. Not marked: it is the real Collapsible’s own part (data-slot="collapsible"), which takes no attribute for it |
| `trigger` | `button` | `thinking-state-trigger` |  | The collapsible's inline trigger: hover --fndn-hover, press --fndn-hover-2. Not marked: it is the real Collapsible’s own part (data-slot="collapsible-trigger"), which takes no attribute for it |
| `header` | `span` | `thinking-state-header` |  | The trigger's label part: the sparkle and the live label. Not marked: it is the real Collapsible’s own part (data-slot="collapsible-label"), which takes no attribute for it |
| `icon` | `span` | `thinking-state-icon` |  | Sparkle by default; decorative |
| `label` | `span` | `thinking-state-label` |  | role=status live region; stays mounted while its text is swapped |
| `label-text` | `span` | `thinking-state-label-text` |  | The current label. While working it is the real Shimmer (fast), marked data-thinking-state="label-text"; a replacement text arrives out of a 2px blur |
| `rail` | `div` | `thinking-state-rail` |  |  |
| `line` | `span` | `thinking-state-line` |  | Hairline under the sparkle; the adapter sets its height so it grows to meet a row that arrives |
| `rows` | `div` | `thinking-state-rows` |  |  |
| `query` | `div` | `thinking-state-query` | optional | search variant: search icon + query text |
| `row` | `div` | `thinking-state-row` | repeats | div, a (href) or button (pressable, aria-pressed). --fndn-row-index only on rows present at first render |
| `check` | `span` | `thinking-state-check` | optional | steps variant: check mark, or a spinner on the last row while working |
| `primary` | `span` | `thinking-state-primary` |  | Truncates on one line (title carries the full text); wraps in the reasoning variant |
| `secondary` | `span` | `thinking-state-secondary` | optional | Muted note; data-mono for file names and commands |
| `diff` | `span` | `thinking-state-diff` | optional | +added −removed counts |
| `dot` | `span` | `thinking-state-dot` | optional | search variant: colored globe disc per source, data-tone cycles accent/orange/green |
| `more` | `span` | `thinking-state-more` | optional | search variant: '+7 more' trailer; fades in place |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"steps" \| "reasoning" \| "search" \| "coding"` | `"steps"` | steps: check/spinner rows; reasoning: prose rows; search: query + link rows with globe dots; coding: pressable tool rows |
| `working` | `boolean` | `false` | data-state=working\|done |
| `expanded` | `boolean` | `false` | Bindable (React: `defaultExpanded` and `onExpandedChange`; Vue: `v-model:expanded`; Svelte: `bind:expanded`). The trace is open. React: expanded / defaultExpanded / onExpandedChange; Vue: v-model:expanded; Svelte: bind:expanded. |
| `activeLabel` | `string` | `"Thinking"` |  |
| `doneLabel` | `string` | `"Done thinking"` |  |
| `rows` | `{ primary: string; secondary?: string; mono?: boolean; add?: number; del?: number; href?: string }[]` |  | Controlled. Rows present at first render stagger in with appear; a row appended later fades up alone. |
| `query` | `string` |  | search variant: the query shown above the sources |
| `more` | `string` |  | search variant: trailer text such as '+7 more' |
| `pressable` | `boolean` | `false` | Rows are buttons with aria-pressed (defaults on for coding). |
| `tone` | `"accent" \| "orange" \| "green"` | `"accent"` | search dot tint, cycles by row index |
| `selected` | `number` |  | Bindable (React: `defaultSelected` and `onSelectedChange`; Vue: `v-model:selected`; Svelte: `bind:selected`). Index of the pressed row (aria-pressed), or null. Pressable rows single-select. |
| `appear` | `boolean` | `false` | Whether the rows (and the search query and trailer) present at mount fade up, staggered. Off by default: set it on the trace your code adds live, never on one rendered from history or with the page (a mount is not an arrival). Rows added after mount enter either way. |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `toggle` | (expanded: boolean) |
| `rowClick` | (row, index) when a row is pressable |
| `selectedChange` | (index \| null) |

## Slots

| Slot | Content |
| --- | --- |
| `icon` | replace the sparkle |

## States

`working`, `done`, `expanded`, `collapsed`, `row-hover`, `row-press`, `row-focus-visible`, `row-selected`

## Keyboard and accessibility

Keyboard:

- Tab reaches the header; Enter / Space expand or collapse the trace, focus stays on the header
- While collapsed, the rows are out of the tab order
- search: Tab moves through the source links; Enter opens one
- coding: Tab moves through the tool rows; Enter / Space press one (aria-pressed), pressing it again releases it

Notes:

- The header is a real button with aria-expanded and aria-controls pointing at the trace.
- The label is a role=status region that stays mounted; only its text changes, so working → done is announced once.
- Checks, spinners, dots and the sparkle are aria-hidden.
- Truncated row text carries the full value in title.

## Motion

- mount: nothing plays unless appear is set; with appear, rows present at first render fade up over duration.enter, staggered by duration.stagger and capped at motion.stagger-max; the header and the rail do not move
- expand / collapse: the collapsible reveals the trace as one container (its reveal recipe; instant from the keyboard); rows do not enter again; the caret turns from right to down over duration.move
- working → done: the label text is swapped through a short blur (opacity + filter over duration.base); the spinner hands over to a check that scales in from 0.5 (duration.press). Transitions armed by data-ready, so nothing plays at first paint
- a row added after mount always fades up alone with no delay; the rail line grows to meet it over duration.move
- label shimmer while working: the Shimmer (fast); under reduced motion it stops and shows static ink-2 text
- search: animated underline on the source name on hover and focus (duration.slow, easing.link)
- keyboard: nothing here animates on a key press except the reveal the user asked for

## Tokens

`color.ink`, `color.ink-2`, `color.ink-3`, `color.line`, `color.hover`, `color.hover-2`, `color.inset`, `color.green`, `color.red`, `color.orange`, `color.accent`, `color.on-accent`, `radius.chip`, `text.2xs`, `text.xs`, `text.sm`, `font.mono`, `easing.out-strong`, `easing.link`, `duration.fast`, `duration.base`, `duration.press`, `duration.move`, `duration.slow`, `duration.enter`, `duration.stagger`, `motion.stagger-max`

## Dependencies

- [Collapsible](/components/collapsible.md)
- [Shimmer](/components/shimmer.md)
- [Spinner](/components/spinner.md)

## Examples

### Review renewals for churn risk

React · `steps.tsx`

```tsx
import { useEffect, useState, type ComponentProps } from "react";
import { ThinkingState } from "@/components/ui/thinking-state";

type Props = ComponentProps<typeof ThinkingState>;

const initial: Props = {
  variant: "steps",
  working: true,
  defaultExpanded: true,
  activeLabel: "Reviewing December renewals",
  doneLabel: "Reviewed 38 renewals",
  rows: [
    { primary: "Loading December renewals", secondary: "38 accounts" },
    { primary: "Comparing bookings with the last 90 days" },
    { primary: "Matching open support tickets", secondary: "112 tickets" },
    { primary: "Scoring churn risk per account" },
  ],
};

/* each step waits `after` ms, then merges its props over the current ones */
const timeline: { after: number; props: Partial<Props> }[] = [
  {
    after: 1100,
    props: {
      rows: [
        { primary: "Loading December renewals", secondary: "38 accounts" },
        { primary: "Comparing bookings with the last 90 days" },
        { primary: "Matching open support tickets", secondary: "112 tickets" },
        { primary: "Scoring churn risk per account" },
        { primary: "Ranking by revenue at risk" },
      ],
    },
  },
  {
    after: 1200,
    props: {
      rows: [
        { primary: "Loading December renewals", secondary: "38 accounts" },
        { primary: "Comparing bookings with the last 90 days" },
        { primary: "Matching open support tickets", secondary: "112 tickets" },
        { primary: "Scoring churn risk per account" },
        { primary: "Ranking by revenue at risk" },
        { primary: "Writing the summary for Sofia Alvarez", secondary: "1 page" },
      ],
    },
  },
  { after: 1400, props: { working: false } },
];

export default function Steps() {
  const [props, setProps] = useState(initial);
  useEffect(() => {
    let i = 0, timer = 0;
    const next = () => {
      const step = timeline[i++];
      if (step) timer = window.setTimeout(() => { setProps((p) => ({ ...p, ...step.props })); next(); }, step.after);
    };
    next();
    return () => clearTimeout(timer);
  }, []);
  return <ThinkingState {...props} />;
}
```

Vue · `steps.vue`

```vue
<script setup lang="ts">
import { onBeforeUnmount, onMounted, shallowRef } from "vue";
import { ThinkingState } from "@/components/ui/thinking-state";

const initial = {
  variant: "steps",
  working: true,
  expanded: true,
  activeLabel: "Reviewing December renewals",
  doneLabel: "Reviewed 38 renewals",
  rows: [
    { primary: "Loading December renewals", secondary: "38 accounts" },
    { primary: "Comparing bookings with the last 90 days" },
    { primary: "Matching open support tickets", secondary: "112 tickets" },
    { primary: "Scoring churn risk per account" },
  ],
};

/* each step waits `after` ms, then merges its props over the current ones */
const timeline: { after: number; props: Record<string, unknown> }[] = [
  {
    after: 1100,
    props: {
      rows: [
        { primary: "Loading December renewals", secondary: "38 accounts" },
        { primary: "Comparing bookings with the last 90 days" },
        { primary: "Matching open support tickets", secondary: "112 tickets" },
        { primary: "Scoring churn risk per account" },
        { primary: "Ranking by revenue at risk" },
      ],
    },
  },
  {
    after: 1200,
    props: {
      rows: [
        { primary: "Loading December renewals", secondary: "38 accounts" },
        { primary: "Comparing bookings with the last 90 days" },
        { primary: "Matching open support tickets", secondary: "112 tickets" },
        { primary: "Scoring churn risk per account" },
        { primary: "Ranking by revenue at risk" },
        { primary: "Writing the summary for Sofia Alvarez", secondary: "1 page" },
      ],
    },
  },
  { after: 1400, props: { working: false } },
];

const props = shallowRef<Record<string, unknown>>({ ...initial });
let timer = 0;
onMounted(() => {
  let i = 0;
  const next = () => {
    const step = timeline[i++];
    if (step) timer = window.setTimeout(() => { props.value = { ...props.value, ...step.props }; next(); }, step.after);
  };
  next();
});
onBeforeUnmount(() => clearTimeout(timer));
</script>

<template>
  <ThinkingState v-bind="props" />
</template>
```

Svelte · `steps.svelte`

```svelte
<script lang="ts">
  import { onMount } from "svelte";
  import { ThinkingState } from "$lib/components/ui/thinking-state";

  const initial = {
    variant: "steps",
    working: true,
    expanded: true,
    activeLabel: "Reviewing December renewals",
    doneLabel: "Reviewed 38 renewals",
    rows: [
      { primary: "Loading December renewals", secondary: "38 accounts" },
      { primary: "Comparing bookings with the last 90 days" },
      { primary: "Matching open support tickets", secondary: "112 tickets" },
      { primary: "Scoring churn risk per account" },
    ],
  };

  /* each step waits `after` ms, then merges its props over the current ones */
  const timeline: { after: number; props: Record<string, unknown> }[] = [
    {
      after: 1100,
      props: {
        rows: [
          { primary: "Loading December renewals", secondary: "38 accounts" },
          { primary: "Comparing bookings with the last 90 days" },
          { primary: "Matching open support tickets", secondary: "112 tickets" },
          { primary: "Scoring churn risk per account" },
          { primary: "Ranking by revenue at risk" },
        ],
      },
    },
    {
      after: 1200,
      props: {
        rows: [
          { primary: "Loading December renewals", secondary: "38 accounts" },
          { primary: "Comparing bookings with the last 90 days" },
          { primary: "Matching open support tickets", secondary: "112 tickets" },
          { primary: "Scoring churn risk per account" },
          { primary: "Ranking by revenue at risk" },
          { primary: "Writing the summary for Sofia Alvarez", secondary: "1 page" },
        ],
      },
    },
    { after: 1400, props: { working: false } },
  ];

  let props: Record<string, unknown> = $state.raw({ ...initial });
  onMount(() => {
    let i = 0, timer = 0;
    const next = () => {
      const step = timeline[i++];
      if (step) timer = window.setTimeout(() => { props = { ...props, ...step.props }; next(); }, step.after);
    };
    next();
    return () => clearTimeout(timer);
  });
</script>

<ThinkingState {...props} />
```

### Decide whether to roll back a deploy

React · `reasoning.tsx`

```tsx
import type { ComponentProps } from "react";
import { ThinkingState } from "@/components/ui/thinking-state";

type Props = ComponentProps<typeof ThinkingState>;

const rows: Props["rows"] = [
  {
    primary: "Errors on harbor/api rose from 0.2% to 4.1% right after the 14:05 deploy, and every failing request hits /v2/availability.",
  },
  {
    primary: "Rolling back to #481 is safe: migration 0142 only adds a nullable column, so the previous build still reads the bookings table.",
  },
];

export default function Reasoning() {
  return (
    <ThinkingState
      variant="reasoning"
      defaultExpanded
      doneLabel="Thought for 6 seconds"
      rows={rows}
    />
  );
}
```

Vue · `reasoning.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { ThinkingState } from "@/components/ui/thinking-state";

const expanded = ref(true);

const rows = [
  {
    primary: "Errors on harbor/api rose from 0.2% to 4.1% right after the 14:05 deploy, and every failing request hits /v2/availability.",
  },
  {
    primary: "Rolling back to #481 is safe: migration 0142 only adds a nullable column, so the previous build still reads the bookings table.",
  },
];
</script>

<template>
  <ThinkingState
    variant="reasoning"
    v-model:expanded="expanded"
    doneLabel="Thought for 6 seconds"
    :rows="rows"
  />
</template>
```

Svelte · `reasoning.svelte`

```svelte
<script lang="ts">
  import { ThinkingState } from "$lib/components/ui/thinking-state";

  let expanded = $state(true);

  const rows = [
    {
      primary: "Errors on harbor/api rose from 0.2% to 4.1% right after the 14:05 deploy, and every failing request hits /v2/availability.",
    },
    {
      primary: "Rolling back to #481 is safe: migration 0142 only adds a nullable column, so the previous build still reads the bookings table.",
    },
  ];
</script>

<ThinkingState
  variant="reasoning"
  bind:expanded={expanded}
  doneLabel="Thought for 6 seconds"
  rows={rows}
/>
```

### Research a database connection error

React · `search.tsx`

```tsx
import type { ComponentProps } from "react";
import { ThinkingState } from "@/components/ui/thinking-state";

type Props = ComponentProps<typeof ThinkingState>;

const rows: Props["rows"] = [
  {
    primary: "PgBouncer configuration",
    secondary: "pgbouncer.org",
    href: "https://www.pgbouncer.org/config.html",
  },
  {
    primary: "Number of database connections",
    secondary: "wiki.postgresql.org",
    href: "https://wiki.postgresql.org/wiki/Number_Of_Database_Connections",
  },
  {
    primary: "Connections and authentication",
    secondary: "postgresql.org",
    href: "https://www.postgresql.org/docs/current/runtime-config-connection.html",
  },
];

export default function Search() {
  return (
    <ThinkingState
      variant="search"
      defaultExpanded
      doneLabel="Searched the web"
      query="postgres too many connections with pgbouncer"
      more="+5 more"
      rows={rows}
    />
  );
}
```

Vue · `search.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { ThinkingState } from "@/components/ui/thinking-state";

const expanded = ref(true);

const rows = [
  {
    primary: "PgBouncer configuration",
    secondary: "pgbouncer.org",
    href: "https://www.pgbouncer.org/config.html",
  },
  {
    primary: "Number of database connections",
    secondary: "wiki.postgresql.org",
    href: "https://wiki.postgresql.org/wiki/Number_Of_Database_Connections",
  },
  {
    primary: "Connections and authentication",
    secondary: "postgresql.org",
    href: "https://www.postgresql.org/docs/current/runtime-config-connection.html",
  },
];
</script>

<template>
  <ThinkingState
    variant="search"
    v-model:expanded="expanded"
    doneLabel="Searched the web"
    query="postgres too many connections with pgbouncer"
    more="+5 more"
    :rows="rows"
  />
</template>
```

Svelte · `search.svelte`

```svelte
<script lang="ts">
  import { ThinkingState } from "$lib/components/ui/thinking-state";

  let expanded = $state(true);

  const rows = [
    {
      primary: "PgBouncer configuration",
      secondary: "pgbouncer.org",
      href: "https://www.pgbouncer.org/config.html",
    },
    {
      primary: "Number of database connections",
      secondary: "wiki.postgresql.org",
      href: "https://wiki.postgresql.org/wiki/Number_Of_Database_Connections",
    },
    {
      primary: "Connections and authentication",
      secondary: "postgresql.org",
      href: "https://www.postgresql.org/docs/current/runtime-config-connection.html",
    },
  ];
</script>

<ThinkingState
  variant="search"
  bind:expanded={expanded}
  doneLabel="Searched the web"
  query="postgres too many connections with pgbouncer"
  more="+5 more"
  rows={rows}
/>
```

### Fix a failing test

React · `coding.tsx`

```tsx
import type { ComponentProps } from "react";
import { ThinkingState } from "@/components/ui/thinking-state";

type Props = ComponentProps<typeof ThinkingState>;

const rows: Props["rows"] = [
  { primary: "Read", secondary: "src/booking/availability.test.ts", mono: true },
  {
    primary: "Edit",
    secondary: "src/booking/availability.ts",
    mono: true,
    add: 18,
    del: 6,
  },
  { primary: "Run", secondary: "pnpm test availability", mono: true },
];

export default function Coding() {
  return (
    <ThinkingState
      variant="coding"
      defaultExpanded
      defaultSelected={1}
      doneLabel="Ran 3 tools"
      rows={rows}
    />
  );
}
```

Vue · `coding.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { ThinkingState } from "@/components/ui/thinking-state";

const expanded = ref(true);

const selected = ref(1);

const rows = [
  { primary: "Read", secondary: "src/booking/availability.test.ts", mono: true },
  {
    primary: "Edit",
    secondary: "src/booking/availability.ts",
    mono: true,
    add: 18,
    del: 6,
  },
  { primary: "Run", secondary: "pnpm test availability", mono: true },
];
</script>

<template>
  <ThinkingState
    variant="coding"
    v-model:expanded="expanded"
    v-model:selected="selected"
    doneLabel="Ran 3 tools"
    :rows="rows"
  />
</template>
```

Svelte · `coding.svelte`

```svelte
<script lang="ts">
  import { ThinkingState } from "$lib/components/ui/thinking-state";

  let expanded = $state(true);

  let selected = $state(1);

  const rows = [
    { primary: "Read", secondary: "src/booking/availability.test.ts", mono: true },
    {
      primary: "Edit",
      secondary: "src/booking/availability.ts",
      mono: true,
      add: 18,
      del: 6,
    },
    { primary: "Run", secondary: "pnpm test availability", mono: true },
  ];
</script>

<ThinkingState
  variant="coding"
  bind:expanded={expanded}
  bind:selected={selected}
  doneLabel="Ran 3 tools"
  rows={rows}
/>
```

## Recipe

`thinking-state.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* thinking-state — expandable agent trace.
 * Header: the real Collapsible (inline, caret first): caret · sparkle · shimmering label while
 * working (the real Shimmer, fast), settles to ink-2. The caret leads, as in tool-chips' run header,
 * so the label changing length ("Thinking" → "Thought for 4s") moves nothing under the pointer. The sparkle and the live label sit in the collapsible's
 * label part, laid out by the header slot (passed as the Collapsible's labelClass).
 * Trace: a hairline rail that grows as rows arrive (check / spinner · primary · secondary).
 * Fully controlled: working, aria-expanded and the rows come from the host.
 *
 * Motion (`docs motion`), all here:
 *   mount     a mount is not an arrival: a plain mount shows its rows at once. With appear (the
 *             host's prop, for a trace its code adds live) the rows present at first render fade
 *             up, staggered and capped (--fndn-row-index, set by the adapter only on those rows);
 *             the header does not move
 *   expand    the collapsible (keepLayout) reveals the trace as one container; its rows do not enter again
 *   status    working → done swaps the label text through a short blur, the spinner hands over
 *             to a check that scales in from 0.5; both start from @starting-style scoped to
 *             the ready variant, so nothing plays at first paint
 *   arrival   a row that arrives later fades up alone, the rail grows to meet it (height, set by
 *             the adapter: a 1px, absolutely positioned, childless hairline; nothing reflows)
 */

export const thinkingState = tv({
  slots: {
    base: "flex flex-col w-full max-w-[380px] min-w-0 text-sm",
    /* the collapsible's label part (passed as its labelClass): the sparkle and the live label in a row */
    header: "inline-flex items-center gap-2",
    icon: [
      "inline-flex shrink-0 size-4 items-center justify-center text-[16px] text-ink-3 motion-colors-base",
      "[&>svg:not([data-slot=icon])]:size-full",
    ],
    /* the live region; its text node is swapped, never the region itself */
    label: "inline-flex min-w-0",
    /* a text that replaces another arrives out of a 2px blur, which masks the swap */
    labelText: [
      "inline-block min-w-0 overflow-hidden text-ellipsis opacity-100 [filter:blur(0)] motion-opacity-base motion-filter-base",
    ],
    rail: "relative mt-1 ms-[5px] ps-4",
    /* the hairline under the sparkle: stretched with `bottom` until the adapter has measured the
     * rows, then a height that grows to meet a row that arrives */
    /* centred under the caret, which leads the header */
    line: "absolute -top-2 bottom-1.5 start-[1.5px] w-px bg-line motion-size-move data-measured:bottom-auto",
    rows: "flex flex-col gap-1 min-w-0 py-1",
    query: [
      "flex min-h-6 min-w-0 items-center gap-2 px-1.5 text-dense text-ink-2 animate-fade-up",
      "[&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[14px] [&>[data-slot=icon]]:text-ink-3",
      "[&>span]:min-w-0 [&>span]:overflow-hidden [&>span]:text-ellipsis [&>span]:whitespace-nowrap [&>span]:[unicode-bidi:plaintext]",
    ],
    row: [
      "flex items-center gap-2 min-h-7 w-full min-w-0 px-1.5 py-0.5 rounded-chip text-dense text-start text-inherit no-underline",
      "motion-colors-fast",
      /* rows present at first render carry --fndn-row-index; a row that arrives later enters at once */
      "animate-[fndn-fade-up_var(--fndn-duration-enter)_var(--fndn-easing-out-strong)_calc(min(var(--fndn-row-index,0),var(--fndn-motion-stagger-max))*var(--fndn-duration-stagger))_both]",
      /* links and buttons: hover, pressed (aria-pressed), press; the trace clips, so the ring sits inside */
      "[&:is(a,button)]:hover:not-aria-pressed:not-active:bg-hover",
      "aria-pressed:not-active:bg-inset",
      "[&:is(a,button)]:active:bg-hover-2",
      "[&:is(a,button)]:focus-visible:outline-offset-[-2px]",
    ],
    /* steps: a check, or a spinner on the last row while working; a check that takes over from
     * the spinner scales in */
    check: [
      "inline-flex shrink-0 size-3.5 items-center justify-center text-[14px] text-ink-3",
      "[&>[data-slot=icon]]:motion-opacity-base [&>[data-slot=icon]]:motion-transform-press",
    ],
    primary: "flex-[0_1_auto] min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-medium text-ink [unicode-bidi:plaintext]",
    /* the detail ("1,248 line items") keeps its width up to 60% of the row; the primary yields first */
    secondary: "flex-none max-w-[60%] min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[11.5px] text-ink-2 [unicode-bidi:plaintext]",
    /* a count reads "+12480" / "-9731" on a right-to-left page too */
    diff: [
      "inline-flex shrink-0 gap-1 font-mono text-2xs tabular-nums whitespace-nowrap",
      "[&>*]:[direction:ltr] [&>*]:[unicode-bidi:isolate] [&>[data-add]]:text-green [&>[data-del]]:text-red",
    ],
    /* search: a coloured globe disc per source */
    dot: "inline-flex shrink-0 size-3.5 items-center justify-center rounded-[50%] bg-accent text-[9px] text-on-accent",
    /* decoration: fades in place, after the rows */
    more: "px-1.5 text-xs text-ink-2 animate-[fndn-fade-in_var(--fndn-duration-enter)_ease_calc(min(var(--fndn-row-index,0),var(--fndn-motion-stagger-max))*var(--fndn-duration-stagger))_both]",
  },
  variants: {
    /* appear=false (the default): the rows, query and trailer present at mount are simply there;
     * what is added later still enters. Set per part by the adapter. */
    appear: { true: {}, false: { row: "animate-none", query: "animate-none", more: "animate-none" } },
    /* working: the sparkle reads ink-2 while the label shimmers */
    working: { true: { icon: "text-ink-2" } },
    /* set after the first render: status swaps animate from @starting-style, first paint does not */
    ready: {
      true: {
        labelText: "starting:opacity-0 starting:[filter:blur(2px)]",
        check: "[&>[data-slot=icon]]:starting:opacity-0 [&>[data-slot=icon]]:starting:[transform:scale(0.5)]",
      },
    },
    /* a row whose detail is code */
    mono: { true: { secondary: "font-mono" } },
    /* search: the source disc's colour, by order */
    tone: { accent: {}, orange: { dot: "bg-orange" }, green: { dot: "bg-green" } },
    variant: {
      steps: {},
      reasoning: {
        row: "items-start",
        primary: "whitespace-normal wrap-anywhere leading-[1.6] font-normal text-ink-2",
      },
      /* an underline that draws under the source name; inside the box, so the truncation clip keeps it */
      search: {
        primary: [
          "relative after:content-[''] after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-current",
          "after:[transform:scaleX(0)] after:origin-[left_center] [&:dir(rtl)]:after:origin-[right_center]",
          "after:motion-also-[transform_var(--fndn-duration-slow)_var(--fndn-easing-link)]",
          "[@media(hover:hover)_and_(pointer:fine)]:[[data-slot=thinking-state-row]:hover_&]:after:[transform:scaleX(1)]",
          "[[data-slot=thinking-state-row]:focus-visible_&]:after:[transform:scaleX(1)]",
        ],
      },
      coding: { row: "cursor-pointer" },
    },
  },
  defaultVariants: { variant: "steps" },
});

export type ThinkingStateRecipeProps = VariantProps<typeof thinkingState>;
```
