Thinking Block
A host-fed, collapsible reasoning panel with optional task steps and pending/running/completed/failed/cancelled statuses.
A host-fed panel for a reasoning trace and optional steps. It can render partial plain text or Markdown, show per-step pending/running/done/failed/cancelled status, and select a host-owned step. ThinkingBlock does not advance a run; the host provides all content, step status, selection callbacks and streaming state.
Import
import { ThinkingBlock } from "@yuhuanowo/yunui/ai";Basic
Basic
Streaming
While isStreaming is true, the compact disclosure headline uses the existing text-shimmer motion and a small activity indicator. Explicit labels.title remains the headline; the host supplies all progress.
Streaming
Host-supplied steps
When steps is non-empty, the panel shows the host's ThinkingBlockStep[] instead of the plain-text body. Each step has a stable id, label, optional detail/meta, optional monospace style, and a pending, running, done, failed, or cancelled status. selectedStepId and onStepSelect opt into a host-controlled selection; without the callback, rows stay read-only.
Host-supplied steps
- The host supplied this fixture step.
- Check the public component contracts before answering.
- Waiting for the host to finish the preceding step.
Host-selected step: read
open is the controlled disclosure state; pair it with onOpenChange. Without open, defaultOpen keeps the existing uncontrolled disclosure behavior. If open is supplied without onOpenChange, the trigger is read-only.
Use labels to localize the title and pending/running/completed/failed/cancelled status names.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| content* | string | — | |
| defaultOpen | boolean | false | |
| isStreaming | boolean | false | |
| labels | ThinkingBlockLabels | — | |
| onOpenChange | ((open: boolean) => void) | — | |
| onStepSelect | ((id: string) => void) | — | |
| open | boolean | — | Controlled disclosure state. Without `onOpenChange`, the trigger is read-only. |
| renderContent | ((content: string) => ReactNode) | — | Render reasoning text (e.g. with a Markdown renderer). Defaults to plain pre-wrapped text. |
| selectedStepId | string | — | |
| steps | readonly ThinkingBlockStep[] | [] | Host-supplied detail rows (Steps / Search / Coding / Reasoning). |