Xzero UI
Pro library

Reasoning blockPro

The collapsible thinking block of an AI reply. While the model thinks, a shimmering label counts the seconds and the latest reasoning streams underneath. When it finishes, it folds to "Thought for 7s" and opens to show the full reasoning as calm steps with headings.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/reasoning-block
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/reasoning-block

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { ReasoningBlock } from "@/components/xzero/reasoning-block/reasoning-block";

// While streaming: pass the growing text, then flip status when the answer starts.
<ReasoningBlock
  reasoning={thinkingText}
  status={done ? "done" : "thinking"}
  onStop={() => controller.abort()}
/>

// A finished message from history.
<ReasoningBlock reasoning={message.reasoning} status="done" seconds={message.thinkingSeconds} />

API reference

ReasoningBlock

The collapsible thinking block of an AI reply. While the model thinks, a shimmering "Thinking" label counts the seconds and the latest reasoning streams under it in muted text, two lines tall. When it finishes it collapses to "Thought for 7s" with a chevron; opening it shows the full reasoning as steps with headings on a quiet rail. With no props it plays a simulated Claude session on a loop.

PropTypeDefaultDescription
reasoningstring | ReasoningStep[]–The reasoning so far. Pass the growing string while the model streams: blank lines split paragraphs, and a line written as Heading or ## Heading starts a new step (a half streamed heading never shows raw asterisks). Or pass { title?, text }[] steps.
status"thinking" | "done" | "stopped" | "error""done" when reasoning is passedthinking shimmers the label, counts seconds and streams the latest line; done collapses to "Thought for 7s"; stopped reads "Stopped after 4s"; error shows an alert icon with "Thinking interrupted" and the reason inside.
secondsnumber–Seconds spent thinking, shown as 7s or 1m 12s. Left out, the block measures from the moment status turns thinking. Done without a measurement reads "Thought process".
model{ name: string; mark?: ReactNode }{ name: "Claude Opus 5.5" }Who is thinking. The name labels the block for assistive technology; the mark is an 18px glyph at the left and defaults to the Claude mark in its brand color.
openboolean–Controls whether the full reasoning shows. Pair with onOpenChange.
defaultOpenbooleanfalseOpens the full reasoning on first render.
onOpenChange(open: boolean) => void–Called when the header is pressed.
onStop() => void–Shows a compact Stop action while thinking. Abort your request, then set status to stopped.
onRetry() => void–Shows Retry in the header when status is error.
errorstring–The reason shown at the end of the reasoning when status is error.
variant"card" | "plain""card"card draws a quiet bordered surface; plain drops the border and padding so the block sits flush inside a message bubble.
classNamestring–Class on the root.

parseReasoning

The parser the block uses, exported for tests or for showing a step count elsewhere. Turns a streamed string into { title?, text }[] steps.

PropTypeDefaultDescription
reasoning (required)string | ReasoningStep[] | undefined–Raw streamed reasoning or steps.

ClaudeMark

The Claude mark (Simple Icons, CC0) in its brand color. Pass mono to draw it with currentColor.

PropTypeDefaultDescription
titlestring"Claude"Accessible name.
monobooleanfalseDraws with currentColor instead of #D97757.

Keyboard interactions

KeysAction
TabMoves to the header, then to Stop or Retry when shown, then to Copy reasoning inside the open block.
Enter / SpaceOpens or closes the full reasoning from the header.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in ai

Guidance for AI tools

Reasoning block: The collapsible thinking block of an AI reply. While the model thinks, a shimmering label counts the seconds and the latest reasoning streams underneath. When it finishes, it folds to "Thought for 7s" and opens to show the full reasoning as calm steps with headings. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components