# Thinking

> The thinking view of an AI chat. A live label follows each step, searches and sources fold into a trail, and citations sit beside the answer.

Canonical: https://hextaui.com/blocks/thinking
Last updated: 2026-10-29

## Overview

Long waits feel shorter when you can see the work happening. Thinking puts a live status line at the top of an answer: a small shader orb, the current step in plain words such as “Searching the web”, and a running timer. Open it to read the full trail of searches, sources and reasoning.

Reasoning written as a bold heading followed by a paragraph splits into sections, and half-typed headings are held back until they close. Tool steps show a spinner and a present-tense label while they run, then switch to what they did, with source chips underneath.

The trail opens while the model works and collapses to “Thought for 12s” when it finishes, unless someone has opened or closed it themselves. The answer then cites its sources inline: CitedText turns [1] and [2][3] into compact chips with the title, domain and snippet on hover.

## Installation

### Step 1: Get HextaUI Pro

One payment unlocks every block, including future ones. [See pricing](https://hextaui.com/pricing).

### Step 2: Add the Pro registry to components.json

```json title="components.json"
{
  "registries": {
    "@hextaui-pro": {
      "url": "https://hextaui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${HEXTAUI_PRO_TOKEN}"
      }
    }
  }
}
```

### Step 3: Add your token

Create a token on your [account page](https://hextaui.com/account) and put it in `.env.local` as `HEXTAUI_PRO_TOKEN`.

### Step 4: Add the block

```bash
npx shadcn@latest add @hextaui-pro/thinking
```

## Usage

### With the AI SDK

Map a useChat message’s parts: reasoning parts into Reasoning and text into CitedText, with source-url parts as its sources. Ask the model to cite with [1], [2] at the end of the sentence they support.

```tsx
"use client"

import { useChat } from "@ai-sdk/react"
import type { UIMessage } from "ai"

import { CitedText } from "@/components/blocks/thinking/cited-text"
import { Reasoning } from "@/components/blocks/thinking/reasoning"
import type { Source } from "@/components/blocks/thinking/sources"

function AssistantMessage({ message }: { message: UIMessage }) {
  const sources: Source[] = message.parts.flatMap((part) =>
    part.type === "source-url"
      ? [{ id: part.sourceId, url: part.url, title: part.title ?? part.url }]
      : []
  )

  return (
    <div className="flex flex-col gap-4">
      {message.parts.map((part, index) => {
        if (part.type === "reasoning") {
          return (
            <Reasoning
              key={index}
              text={part.text}
              streaming={part.state === "streaming"}
            />
          )
        }
        if (part.type === "text") {
          return (
            <CitedText
              key={index}
              text={part.text}
              sources={sources}
              streaming={part.state === "streaming"}
            />
          )
        }
        return null
      })}
    </div>
  )
}

export function Chat() {
  const { messages } = useChat()

  return messages.map((message) =>
    message.role === "assistant" ? (
      <AssistantMessage key={message.id} message={message} />
    ) : null
  )
}
```

### With tool steps

Turn tool calls into steps. A call that is still running shows a spinner and a shimmer, and checks off when its output arrives.

```tsx
"use client"

import { getToolName, isToolUIPart, type UIMessage } from "ai"

import { Reasoning, type ReasoningStep } from "@/components/blocks/thinking/reasoning"

const labels: Record<string, Pick<ReasoningStep, "label" | "kind">> = {
  webSearch: { label: "Searching the web", kind: "search" },
  readPage: { label: "Reading sources", kind: "read" },
  runCode: { label: "Running code", kind: "code" },
}

export function Thoughts({
  message,
  streaming,
}: {
  message: UIMessage
  streaming: boolean
}) {
  const steps: ReasoningStep[] = message.parts
    .filter(isToolUIPart)
    .map((part) => {
      const name = getToolName(part)
      return {
        id: part.toolCallId,
        ...(labels[name] ?? { label: name, kind: "think" }),
        status: part.state.startsWith("output") ? "done" : "active",
      }
    })

  const text = message.parts
    .flatMap((part) => (part.type === "reasoning" ? [part.text] : []))
    .join("\n\n")

  return <Reasoning steps={steps} text={text} streaming={streaming} />
}
```

## Anatomy

The parts you compose, from the outside in.

| Part | Description |
| --- | --- |
| `Reasoning` | The collapsible status line and trail. Takes reasoning text, steps, or both. |
| `ThinkingOrb` | The animated shader orb. Use it alone as a compact busy indicator. |
| `CitedText` | The answer, with [n] marks turned into citation chips. |
| `Citation` | One chip with a hover card listing its sources. |
| `SourceChips` | A row of source chips, used under a step. |

## API reference

### Reasoning

Also accepts every div prop except children.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `text` | `string` | `""` | Reasoning so far. **Bold** lines become section headings. |
| `streaming` | `boolean` | `false` | Whether the model is still working. Drives the orb, the shimmer and the timer. |
| `steps` | `ReasoningStep[]` | `[]` | Tool steps shown above the reasoning. |
| `duration` | `number` | – | Seconds to show once finished. Leave it out to use the measured time. |
| `label` | `string` | – | Overrides the live label while streaming. |
| `defaultOpen` | `boolean` | – | Initial open state. Defaults to open while streaming. |
| `autoCollapse` | `boolean` | `true` | Collapse when streaming ends, unless someone toggled it. |

### ReasoningStep

One entry in steps.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id` | `string` | – | Stable key. |
| `label` | `string` | – | What it is doing, for example “Searching for debounce”. |
| `doneLabel` | `string` | – | What it did, shown once status is done. |
| `status` | `"active" \| "done"` | – | Active steps show a spinner and drive the live label. |
| `kind` | `"search" \| "read" \| "think" \| "code"` | `"think"` | Picks the icon and the phase text. |
| `phase` | `string` | – | Custom phase text while the trail is open. |
| `detail` | `ReactNode` | – | Extra content under the step. |
| `sources` | `Source[]` | – | Chips shown under the step. |

### CitedText

Also accepts every div prop except children.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `text` | `string` | – | The answer, with [1]-style marks after the claims. |
| `sources` | `Source[]` | – | Sources in citation order, so [1] is sources[0]. |
| `streaming` | `boolean` | `false` | Shows the caret and paces the text. |
| `smooth` | `boolean` | `true` | Turn pacing off. |

### Source

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id` | `string` | – | Stable key. |
| `url` | `string` | – | Opened in a new tab. |
| `title` | `string` | – | Shown in the hover card. |
| `name` | `string` | – | Short site name for the chip. Defaults to the domain. |
| `snippet` | `string` | – | The quote shown under the title. |
| `icon` | `string` | – | Favicon URL. Falls back to the first letter. |

### ThinkingOrb

Also accepts every span prop.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `active` | `boolean` | – | Animates while true and rests when false. |
| `colors` | `{ deep, mid, light }` | `blue` | Three hex colors for the shader. |
| `speed` | `number` | – | Animation speed multiplier. |

## Keyboard

| Key | Action |
| --- | --- |
| `Tab` | Moves to the status line, then into the trail, then to each citation. A focused citation opens its hover card. |
| `Enter` `Space` | Opens or closes the trail. |
| `Esc` | Closes an open citation card. |

## Accessibility

- The status line is a button that announces its summary through a polite live region, so screen reader users hear “Searching the web”, then “Thought for 12s”, without every timer tick.
- Each citation chip is a real link labelled “Source: MDN: Debounce”, so it reads as a source, not a number.
- With reduced motion the orb renders a still frame, the shimmer stops and rows appear without sliding.

## Built with

The free HextaUI components Thinking is made from. Each one installs on its own.

- [Avatar](https://hextaui.com/docs/avatar) - User photos with an initials fallback, status badges and stacked groups that collapse into a count.
- [Badge](https://hextaui.com/docs/badge) - Status labels with colored dots, removable tags that slide closed and counts that roll to their new value.
- [Bubble](https://hextaui.com/docs/bubble) - Chat message bubbles with variants, grouped corners, reactions and room for interactive content.
- [Collapsible](https://hextaui.com/docs/collapsible) - A panel that shows and hides with height motion you can reverse mid-way, without jumping the layout.
- [Hover card](https://hextaui.com/docs/hover-card) - A preview card that opens when a link is hovered or focused, for content sighted users can glance at.
- [Message](https://hextaui.com/docs/message) - A chat message row with an avatar, name, bubbles and status, where new messages rise in from the sender's side.
- [Spinner](https://hextaui.com/docs/spinner) - A loading indicator with Apple-style ticks or a breathing ring that can wait before showing and stay long enough not to flicker.

## Code

6 files, added to components/blocks/thinking.
