Staaarter

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.

By Staaarter Team
Chat
Docs
Live preview

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.json

Prefer 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

PropTypeDefaultDescription
headingstring"Assistant"Small heading shown in the panel header.
stepsReasoningStep[]noneOrdered reasoning steps rendered inside the collapsible thinking section.
finalAnswerstringnoneThe final answer text, always shown below the thinking section.
classNamestringnoneExtra 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.