Reasoning trail
ProThe agent's thinking chain in a chat: steps on one hairline with their thoughts and sources, streamed with a soft edge, folding into one line when the answer starts, any retry or failure kept.
npx shadcn@latest add @pixilui-pro/reasoning-trailPreview
import { IconFile } from "@/components/pixilui/icons/file";
import { IconQuery } from "@/components/pixilui/icons/query";
import { ReasoningTrail, ReasoningTrailAnswer, ReasoningTrailStream, useReasoningTrailSimulation, type ReasoningTrailSource } from "@/components/pixilui/reasoning-trail";
// The first option of each knob is the demo's default; the docs preview starts there.
export const knobs = {
head: ["action", "working"],
} as const;
/** No animated icon fits a calendar: the static Hugeicons calendar-03 (MIT), drawn inline. */
function IconCalendar({ className }: { className?: string }) {
return (
<svg className={className} viewBox="0 0 24 24" aria-hidden="true">
<g fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.5">
<path d="M16 2v4M8 2v4m5-2h-2C7.229 4 5.343 4 4.172 5.172S3 8.229 3 12v2c0 3.771 0 5.657 1.172 6.828S7.229 22 11 22h2c3.771 0 5.657 0 6.828-1.172S21 17.771 21 14v-2c0-3.771 0-5.657-1.172-6.828S16.771 4 13 4M3 10h18" />
<path d="M12.126 14H12m.125 4H12m-4.376-4H7.5m.125 4H7.5m9.125-4H16.5m-4.25 0a.25.25 0 1 1-.5 0a.25.25 0 0 1 .5 0m0 4a.25.25 0 1 1-.5 0a.25.25 0 0 1 .5 0m-4.5-4a.25.25 0 1 1-.5 0a.25.25 0 0 1 .5 0m0 4a.25.25 0 1 1-.5 0a.25.25 0 0 1 .5 0m9-4a.25.25 0 1 1-.5 0a.25.25 0 0 1 .5 0" />
</g>
</svg>
);
}
const SNOWFLAKE: ReasoningTrailSource = {
id: "query",
name: "Snowflake",
icon: <IconQuery />,
ink: "var(--pixilui-h-tool)",
domain: "Snowflake · retention by source",
quote: "“Week-one retention: 38% before Nov 4. Since then, 41% for all signups, 46% without Product Hunt, and 29% for Product Hunt alone.”",
};
const CALENDAR: ReasoningTrailSource = {
id: "calendar",
name: "Launch calendar",
icon: <IconCalendar />,
ink: "var(--pixilui-h-edit)",
domain: "Launch calendar · Growth",
quote: "“Product Hunt launch, Nov 6. 2,140 signups in the first three days, about four times a normal week.”",
};
const SOURCES: Record<string, ReasoningTrailSource> = {
v2: { id: "v2", name: "Onboarding v2", icon: <IconFile />, ink: "var(--pixilui-h-read)" },
cal: { id: "cal", name: "Launch calendar", icon: <IconCalendar />, ink: "var(--pixilui-h-edit)" },
};
/** A chat turn: the trail plays the reference run, folds into one line with its retry, and the answer streams in with citations. */
export default function ReasoningTrailDemo({ head = "action" }: KnobValues<typeof knobs>) {
const run = useReasoningTrailSimulation();
const steps = run.steps.map((s) => ({ ...s, sources: s.sources?.map((x) => SOURCES[x.id] ?? x) }));
return (
// a centered column, as the lock sets the question and the line
<div className="mx-auto flex w-full max-w-xl flex-col gap-4 rounded-panel bg-surface p-6 elevation-raised">
<p className="self-end rounded-control bg-surface-muted px-3 py-2 type-label text-foreground">Did the new onboarding help retention?</p>
<ReasoningTrail key={head} status={run.status} head={head} defaultOpen={head === "working"} words={run.words} mark={run.mark} flag={run.flag} steps={steps} />
{run.answering ? (
<ReasoningTrailAnswer className="type-body text-foreground">
<ReasoningTrailStream
content={[
{ claim: ["Yes, more than the dashboard shows. Week-one retention went from 38% to ", { strong: "46%" }, " for people who didn't come from the Product Hunt launch.", { cite: [SNOWFLAKE] }] },
" ",
{ claim: ["The overall number reads 41% because launch signups leave faster, and they arrived the same week.", { cite: [CALENDAR] }] },
]}
/>
</ReasoningTrailAnswer>
) : null}
</div>
);
}When to use
Use it when
- Above an agent's answer: what it read, looked up and concluded, as it happens, then one click away.
- An answer with citations: ReasoningTrailStream streams it with the soft edge and ReasoningTrailCitation opens the dark source card that keeps the claim dark.
- A past message: pass the finished steps with status done and it arrives drawn (settled).
Use something else when
- Only the current action and a timer: use thinking state (free), the same line without steps.
- A run's tool calls with inputs and outputs: use the tool call row.
- A run's timeline across many runs: use the run timeline.
Installation
Join the waitlist and we'll email you when PixilUI launches. The preview, props and docs stay open until then.
Pro installs with the same CLI as the free items. One command adds reasoning-trail.tsx and the free thinking-mark.tsx, the free agent-status.tsx, the free thinking-state.tsx and the free chip.tsx it uses; your license key goes in once, as in Installation.
{
"registries": {
"@pixilui-pro": {
"url": "https://pixilui.com/r/pro/{name}.json",
"headers": { "Authorization": "Bearer ${PIXILUI_TOKEN}" }
}
}
}npx shadcn@latest add @pixilui-pro/reasoning-trailAdds reasoning-trail.tsx with thinking-mark.tsx, agent-status.tsx, thinking-state.tsx and chip.tsx, and installs clsx and tailwind-merge. The CLI reads PIXILUI_TOKEN from .env.local; if this computer has not logged in yet, run npx pixilui@latest login once.
components/pixilui/reasoning-trail.tsxthe item, 568 linescomponents/pixilui/thinking-mark.tsxused inside, freecomponents/pixilui/agent-status.tsxused inside, freecomponents/pixilui/thinking-state.tsxused inside, freecomponents/pixilui/chip.tsxused inside, freeIt uses Activity mark, Agent status, Thinking state and Chip: add them the same way. Then npm i clsx tailwind-merge, and add the foundation once per app, as in Installation.
Usage
import { ReasoningTrail } from "@/components/pixilui/reasoning-trail";
<ReasoningTrail steps={steps} />Fills its column; thoughts wrap at the reading measure. The card is 320 wide, kept inside the window, and opens above when there is no room below.
API reference
stepsRequiredReasoningTrailStep[]–The agent's work so far, in order. Add steps as they happen; a step keeps its element by id.thoughtCpsnumber–How fast thoughts stream, letters a second (--pixilui-trail-thought-cps, 70, by default).Keyboard
Accessibility
- The head is a button with aria-expanded; its words are role status, so each phase is announced politely.
- Streaming text is aria-busy until it lands. Citations are buttons named "Source: Snowflake"; the card is role tooltip, tied by aria-describedby.
- Step icons and the mark are aria-hidden. Retries and failures are words, never only a color.
Motion
- A step fades in place and the hairline draws down to it (250ms); its label changes with the quiet swap; the live label carries the text shimmer.
- Thoughts stream at 70 letters a second and the answer at 120 with the soft edge: each letter fades in, so the front is a gradient about 18 letters long, with no cursor; a citation arrives with its text, taking a word's time.
- Source chips gather one at a time, 420ms apart.
- The fold: the time stops, Working becomes Worked for, the flag joins, the steps fade and rise, then the space closes. Opening reverses it, and either turns around halfway.
- A citation's card grows from its pointer below the chip after a short wait (200ms in, 150ms out); the claim stays dark while the rest of the answer dims.
- Reduced motion: text whole at once, chips together, no band, the fold and the card instant.