# Thinking indicator

> Four quiet loaders for the gap before the first token, with a label, a rolling timer and a finish that draws itself.

The second between sending and the first word is where an AI product feels fast or slow. Pick an orbit, dots, a pulse or a scan; each pairs with a label that a light sweeps across and a timer whose seconds roll up as they pass ("Churning 44s"). When it’s done nothing is swapped: the mark blurs into a check that draws itself, the label morphs to "Done in" and the time gains its tenths, "44.6s".

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/thinking-indicator.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): `number-roll`, `text-morph`
- Docs and live preview: https://hairlineui.com/ui/thinking-indicator
- Registry item (source): https://hairlineui.com/r/thinking-indicator.json

## Usage

```tsx
import { ThinkingIndicator } from "@/components/thinking-indicator";

<ThinkingIndicator variant="orbit" label="Churning" startedAt={sentAt} />
```

## With the AI SDK

```tsx
import { useChat } from "@ai-sdk/react";
import { useState } from "react";
import { ThinkingIndicator } from "@/components/thinking-indicator";

function Waiting() {
  const { status, sendMessage } = useChat();
  const [sentAt, setSentAt] = useState<number>();

  const send = (text: string) => {
    setSentAt(Date.now());
    sendMessage({ text });
  };

  // "submitted" is the gap between sending and the first streamed token.
  return status === "submitted" ? <ThinkingIndicator startedAt={sentAt} /> : null;
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"orbit" \| "dots" \| "pulse" \| "scan"` | `"orbit"` | The mark. |
| `status` | `"running" \| "done"` | `"running"` | Animating, or settled with a check. |
| `label / doneLabel` | `string` | `"Thinking"` | What it says while running, and once done. |
| `startedAt` | `number` | – | Start time in ms; shows the rolling timer and times "Done in". |

## States

- **running**: The mark animates, a 1.4s sweep of light crosses the label and the seconds roll up once a second. At a minute, the minutes slide open ("1m 05s").
- **done**: The mark shrinks away through a blur and pauses; a check draws itself (420ms); the label morphs to "Done in" and the tenths slide open: "Done in 12.4s". A doneLabel replaces the whole line, and the timer folds away.

## What it handles

The second between sending a message and the first word is where an AI product feels fast or slow. This fills it with something calm, and says how long the thinking took.

- **Four marks to choose from**: An orbit, dots, a pulse or a scan.
- **A label with a sweep**: A sweep of light crosses the label while it runs.
- **A timer that rolls**: The seconds roll up as they pass (“Churning 44s”), and minutes open at one minute.
- **Done without a swap**: The mark blurs into a check that draws itself, and the label morphs to “Done in 44.6s”.
- **Your own words**: Set the label while running, and a doneLabel for the end.
- **Quiet for screen readers**: The label and the done message are announced. The ticking timer is hidden.

## Replaces

a loading spinner, a “Thinking…” label, an elapsed timer, a done state, a shimmer on text

## Where it fits

- **AI chat apps**: The gap between sending a message and the first word of the answer.
- **Search and research tools**: A calm “Searching” state while results are gathered.
- **Agent tools**: A working indicator for a task that takes a few seconds.
- **Generation tools**: The wait while an image, a summary or a report is prepared.

## Notes

- A status region announces the label and then the done message ("Done in 12.4s"); the ticking timer itself is hidden from screen readers.
- The timer re-renders once a second, on the second, and stops when done or unmounted. The mark’s animation is paused once it has faded out.
- Installs Number roll and Text morph. With reduced motion the marks hold still, nothing sweeps or rolls, and states change in place.

License: MIT (https://hairlineui.com/license#components)
