AI Reasoning Steps with Collapsible Thinking
A chat response with a collapsed-by-default "thinking" section that a visitor can expand with a Show thinking toggle. Inside, each reasoning step is independently collapsible and carries a fixed elapsed-time badge. A polished final-answer block is always shown below the thinking section regardless of whether it's expanded.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its badge dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/ai-reasoning-steps-collapsible.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/chat/chat13.tsx instead.
Usage
The file also exports chat13Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Chat13, chat13Demo } from "@/components/blocks/chat/chat13"; export default function Page() { return <Chat13 {...chat13Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Assistant" | Small heading shown in the panel header. |
| steps | ReasoningStep[] | none | Ordered reasoning steps rendered inside the collapsible thinking section. |
| finalAnswer | string | none | The final answer text, always shown below the thinking section. |
| className | string | none | Extra classes for the outer panel element. |
Types
export interface ReasoningStep { id: string; title: string; detail: string; time: string; }
Behavior notes
- The whole thinking section is collapsed by default and toggled by a real useState boolean (Show thinking / Hide thinking), with a rotating chevron.
- Each step is independently collapsible via a `Set<string>` of open step ids in useState, so expanding one step doesn't affect the others.
- The `time` badge on each step (e.g. "1.2s") is a fixed literal string passed in as data, it is decorative and not computed from Date.now() or any real timer.
- The final-answer block always renders regardless of the thinking section's open/closed state.
More Chat Blocks
View all →rich-prompt-input-with-suggestions
Rich Prompt Input with Smart Suggestions
An AI prompt composer with attachment icons, a model selector, and a grid of clickable prompt suggestion cards.
ai-streaming-response-typewriter
AI Streaming Response with Live Typing
A single AI chat exchange with a skeleton loading state, a word-by-word typewriter reveal, and a stop-generating control.
ai-response-with-cited-sources
AI Response with Cited Sources
A Perplexity-style answer with inline numbered citation markers and an expandable source list below it.
code-generation-chat-with-syntax-highlighting
Code Generation Chat with Syntax Highlighting
A developer chat message with a file-name tab bar, a language badge, illustrative syntax coloring, and a real copy button.
prompt-starter-grid
AI Prompt Starter Grid
A tabbed grid of prompt template cards, filterable by category, each with an icon, title, and description.
ai-agent-profile-card
AI Agent Profile Card
A showcase card for an AI agent with avatar, capability badges, a sample chat preview, stats, and action buttons.