Aadi

Reasoning

AI chats 7

About

A model's thinking block that streams in with a live step summary and elapsed time, then settles into a collapsible summary.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Reasoning to your project and fits it to your theme.

Code

How Reasoning is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client"

import * as React from "react"
import { Reasoning } from "@/components/ui/reasoning"

const THOUGHTS = `**Reading the failing test**

The snapshot test for RecentRuns fails only in CI. Locally the dates render as "Oct 21", in CI as "21 Oct", so the formatter is picking up the machine locale.

**Finding where the date is formatted**

formatRunDate calls toLocaleDateString() with no locale argument. Passing "en-US" and a fixed time zone makes the output stable everywhere.

**Checking other callers**

Two more components use the same helper. Fixing it at the source covers all three without touching the snapshots.`

/** Streams a model's thinking in, then settles into a summary you can reopen. Loops. */
export default function ReasoningDemo() {
  // Starts partway in, so the first frame already shows thinking.
  const [length, setLength] = React.useState(Math.round(THOUGHTS.length * 0.4))
  const [run, setRun] = React.useState(0)
  const done = length >= THOUGHTS.length

  React.useEffect(() => {
    const id = window.setTimeout(
      () => {
        if (done) {
          setLength(0)
          setRun((r) => r + 1)
        } else setLength((n) => Math.min(THOUGHTS.length, n + 10))
      },
      done ? 5000 : length === 0 ? 300 : 110,
    )
    return () => window.clearTimeout(id)
  }, [length, done])

  return (
    <div className="flex h-[460px] w-full items-start justify-center overflow-hidden p-6 pt-12">
      <div className="w-full max-w-xl">
        <Reasoning key={run} defaultOpen text={THOUGHTS.slice(0, length)} state={done ? "done" : "streaming"} />
      </div>
    </div>
  )
}

Dependencies

More by Aadi

View all
  • Stat Card

    Stat Card

    46
  • Audio Visualizer

    Audio Visualizer

    32
  • Dither Orb

    Dither Orb

    24
  • Voice Orb

    Voice Orb

    20
  • Weather Card

    Weather Card

    18
  • Waveform

    Waveform

    15
  • Ticker Card

    Ticker Card

    15
  • Message Feedback

    Message Feedback

    13

More in AI chats

View all
  • AI Actions

    AI Actions

    351
  • Aquarium Prompt

    Aquarium Prompt

    113
  • Agent Chat

    Agent Chat

    21
  • Message With Header And Delivery Status

    Message With Header And Delivery Status

    60
  • Research Report

    Research Report

    7
  • Tool Web Fetch

    Tool Web Fetch

    4
  • Color Picker

    Color Picker

    201
  • Suggestions

    Suggestions

    40

Explore more

Part of chatcn — browse the full library on 21st.dev.