Loading component…
Loading component…
A small working pill for AI replies
To reuse this local React demo, copy all files from the Code tab into the same folder, then import ThinkingLoader from ./thinking-loader.
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}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| phases | string[] | ["Thinking", "Searching the web", "Reading sources", "Writing response"] | Labels to walk through, one after another |
| interval | number | 2200 | Time per phase in ms when the phase isn't controlled |
| phase | number | Controlled index into phases – the timer stops and the loader shows this phase | |
| loop | boolean | false | Start over after the last phase instead of holding it |
| done | boolean | false | Turns the spinner into a check and the label into doneLabel; setting it back to false starts over |
| doneLabel | string \| ((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 |
| className | string | Extra class on the root |
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"
@import "tailwindcss"; in your main CSS file.