Skip to content
Mizen UI
Docs

IntroductionInstallationCLIStylingFoundationsThemingCompositionIntegrationsAccessibilityFor agents

useCopyToClipboard

AccordionAspect RatioCardCollapsibleFrameGridGroupInlineScroll AreaSectionSeparatorSpacerStack

BlockquoteCitationCodeHeadingKbdLabelLinkTextVisually Hidden

ButtonButton GroupToggleToggle groupToolbar

CalendarCheckboxCheckbox groupComboboxDate pickerDate range pickerDate-Time InputFieldFieldsetFile UploadFormInputInput groupNumber fieldOTP FieldRadio groupSelectSliderSwitchTextareaTime Input

BreadcrumbMenubarNavigation MenuPaginationSegmented ControlStepperTabs

Alert dialogCommandContext MenuDialogDrawerMenuPopoverPreview CardSheetTooltip

AlertBadgeEmptyError StateMeterProgressSkeletonSpinnerStatus dotToast

Activity FeedAvatarAvatar GroupData TableListMetricOverflow ListProperty ListTableTokenTree

Area ChartBar ListCalendar HeatmapCategory ComparisonChart FrameChart LegendChart TooltipDistributionFunnelHeatmapMetric TrendPart-to-WholeProgress RingsRadar ChartRadial BarsSankey ChartScatter ChartScore GaugeTime Series

Diagram

AttachmentCarouselCode BlockLightboxMarkdownThumbnailTimestamp

Agent ThinkingApproval CardComposerConversationInline CitationMessageMessage ScrollerQuestion CardSourcesStreaming TextSuggestionTask ListTerminalTool Call

On this page

  • Preview
  • Usage
  • With the AI SDK
  • With TanStack AI
  • Examples
  • Recommendations
  • Usage boundaries
  • API reference

Agentic

Agent Thinking

Shows a model working before it answers: the current step, the sources it reads, and its reasoning, folding into Thought for Ns.

idle

Usage

import { AgentThinking } from "@mizen-labs/ui";

With the AI SDK

Join the reasoning parts of the latest assistant message. It is thinking while the request is pending or streaming and no answer text has arrived, so the thinking indicator also covers the wait before the first token.

import { useChat } from "@ai-sdk/react";
import { AgentThinking } from "@mizen-labs/ui";

export function AssistantThinking() {
	const { messages, status } = useChat();
	const reply = messages.findLast((message) => message.role === "assistant");
	const parts = reply?.parts ?? [];
	const reasoning = parts
		.flatMap((part) => (part.type === "reasoning" ? [part.text] : []))
		.join("\n\n");
	const answering = parts.some((part) => part.type === "text" && part.text);
	// Thinking until the first words of the answer arrive.
	const thinking =
		(status === "submitted" || status === "streaming") && !answering;
	if (!(thinking || reasoning)) return null;
	return (
		<AgentThinking
			content={reasoning}
			status={thinking ? "streaming" : "complete"}
		/>
	);
}

With TanStack AI

Reasoning arrives as thinking parts with content. The same rule decides when thinking ends: the first answer text.

import { fetchServerSentEvents, useChat } from "@tanstack/ai-react";
import { AgentThinking } from "@mizen-labs/ui";

export function AssistantThinking() {
	const { messages, status } = useChat({
		connection: fetchServerSentEvents("/api/chat"),
	});
	const reply = messages.findLast((message) => message.role === "assistant");
	const parts = reply?.parts ?? [];
	const reasoning = parts
		.flatMap((part) => (part.type === "thinking" ? [part.content] : []))
		.join("\n\n");
	const answering = parts.some((part) => part.type === "text" && part.content);
	const thinking =
		(status === "submitted" || status === "streaming") && !answering;
	if (!(thinking || reasoning)) return null;
	return (
		<AgentThinking
			content={reasoning}
			status={thinking ? "streaming" : "complete"}
		/>
	);
}

Examples

Recommendations

GuidancePractice
Do

Pass the reasoning so far with status streaming, name the current step in stage, and set status to complete when the answer starts. Pass duration when showing a reply from history.

Usage boundaries

GuidanceBoundary
Scope

The application owns the reasoning stream and decides which steps to name. Agent Thinking shows them; it does not run tools or fetch sources.

Scope

Show reasoning the model chose to expose. Some providers only return a summary, or nothing.

API reference

Public props from @mizen-labs/ui. Use exported prop types for the complete TypeScript contract.

PropTypeDefaultDescription
status"streaming" | "complete"—streaming shows the current step with a thinking indicator and the newest lines of reasoning; complete folds into Thought for Ns, which opens to the full reasoning.
contentstring""The reasoning so far. Paragraphs are separated by blank lines; new words resolve out of blur.
stagestring"Thinking"What the model is doing now. Each change is announced politely.
sourcesreadonly StreamingTextSource[][]Sources the model is reading, shown as citation chips as they arrive.
durationnumberMeasuredSeconds spent thinking. Measured while the component watches the stream; pass it for a reply loaded from history.
PreviousTimestampNextApproval Card
Reading the sources

Reading the sources