affectUI › Components › Chat

Thinking Loader

A small working pill for AI replies – an eight-ray spinner and a shimmering label that rolls through phases and settles on a check.

Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/thinking-loader.json · Import from @/components/ui/thinking-loader

When to use

  • The wait between sending a prompt and the first streamed token – one line that says what the model is doing
  • Agent and pipeline steps with real labels: searching, reading, running a tool, writing
  • Inline in a chat bubble or next to a button where a full panel would be too much

When not to use

  • When people should see the sources and every step – use Thinking State
  • Page or data loading with no phases – a skeleton or a plain spinner reads calmer
  • Waits under half a second – the loader would only flash

Usage

import { ThinkingLoader } from "@/components/ui/thinking-loader";

export function AssistantPending({ streaming }: { streaming: boolean }) {
  return (
    <ThinkingLoader
      phases={["Thinking", "Searching the web", "Reading sources", "Writing response"]}
      interval={2200}
      done={streaming}
    />
  );
}

Props

NameTypeDefaultDescription
phasesstring[]["Thinking", "Searching the web", "Reading sources", "Writing response"]Labels to walk through, one after another
intervalnumber2200Time per phase in ms when the phase isn't controlled
phasenumberControlled index into phases – the timer stops and the loader shows this phase
loopbooleanfalseStart over after the last phase instead of holding it
donebooleanfalseTurns the spinner into a check and the label into doneLabel; setting it back to false starts over
doneLabelstring | ((seconds: number) => string)(s) => `Thought for ${s}s`Label once done – a function gets the seconds since the loader started
size"sm" | "md""md"28 or 34px tall
variant"pill" | "plain""pill"A bordered capsule, or just the spinner and the label
classNamestringExtra class on the root

Accessibility

  • role="status" with aria-live="polite": screen readers hear each new phase and the done label once
  • The spinner, the check and the label rolling out are aria-hidden; the shimmer copy has empty alt text, so labels are read once

Responsive

  • Sizes to its label; long phases stay on one line, so keep them short (two to four words)
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Thinking State – AI working panel with a live timer, searched sources and thinking steps that appear one by one
  • AI Answer – Streamed answer with source cards, citation chips that preview their source, copy, regenerate, feedback and follow-ups
  • Chat Composer – Prompt composer with model picker, voice input, app connections and approval request

Guides