Reasoning
A collapsible reasoning disclosure that auto-opens while streaming, counts elapsed seconds with rolling digits, and auto-closes after streaming finishes.
Inspecting active motion tokens and reduced-motion preferences across the container tree.
Measuring collapsible content bounds so spring height transitions avoid layout snaps.
Scheduling post-stream auto-collapse timer after final token arrival.
Customize
Installation
npx shadcn@latest add @kinetic/reasoningUsage
Compose Reasoning, ReasoningTrigger, and ReasoningContent to present model thought traces without overwhelming the chat turn.
import {
Reasoning,
ReasoningContent,
ReasoningTrigger,
} from "@/components/kinetic/ui/reasoning";
export function ThoughtPanel() {
return (
<Reasoning isStreaming={false} duration={4} defaultOpen>
<ReasoningTrigger />
<ReasoningContent>
Checked cached parser tokens and selected the direct AST path.
</ReasoningContent>
</Reasoning>
);
}Streaming and auto-close
When isStreaming flips from false to true, Reasoning opens automatically and starts counting elapsed seconds with RollingDigits. Once isStreaming returns to false, it waits autoCloseDelayMs (default 1000 ms) before collapsing. Pass autoClose={false} or autoCloseDelayMs={0} to keep the panel open, or pass duration explicitly if your backend already tracks elapsed time.
interface StreamThoughtProps {
readonly streaming: boolean;
readonly text: string;
}
export function StreamThought({ streaming, text }: StreamThoughtProps) {
return (
<Reasoning isStreaming={streaming} autoCloseDelayMs={1200}>
<ReasoningTrigger />
<ReasoningContent>{text}</ReasoningContent>
</Reasoning>
);
}Motion preferences
Height changes run on an interruptible spring via useAnimatedSize, while content reveals monotonically from blur to sharp so streaming text growth never re-blurs earlier lines. Use speed (0.45 default) and blurPx (8 default) to tune pacing; reduced motion opens and closes immediately.
API Reference
Reasoning
Zero-dependency streaming reasoning container with RollingDigits elapsed timer, auto-open/auto-close lifecycle, and shared motion tuning.
| Prop | Type | Default | Description |
|---|---|---|---|
open / defaultOpen / onOpenChange | boolean / boolean / (open: boolean) => void | false | Controlled or initial expanded state; defaults to open when isStreaming starts true. |
isStreaming / duration | boolean / number | false / undefined | Drives auto-open, live elapsed second counting via RollingDigits, and delayed auto-close. |
autoClose / autoCloseDelayMs | boolean / number | true / 1000 | Automatically closes after streaming ends; set autoClose={false} or 0 to keep open. |
speed / blurPx | number / number | 0.45 / 8 | Speed multiplier and initial blur radius (px) for content expansion and reveal. |
keepMounted / disabled | boolean / boolean | false / false | Keeps closed content mounted or disables user toggle interactions. |
ReasoningTrigger / ReasoningContent
Rotating-chevron disclosure trigger with RollingDigits timer and monotonic blur-fade height-animated body.
| Prop | Type | Default | Description |
|---|---|---|---|
getThinkingMessage (ReasoningTrigger) | (isStreaming: boolean, duration?: number) => React.ReactNode | - | Optional custom formatter replacing the default thinking and duration label. |
keepMounted / forceMount (ReasoningContent) | boolean / boolean | false | Keeps children mounted while collapsed. |
speed / blurPx (ReasoningContent) | number / number | inherited | Optional per-content overrides for reveal speed and blur radius. |