Xzero UI
Pro library

Reasoning treePro

An illustration of tree search over thoughts: candidates are scored, weak branches fade, the best expand, and the winning path from question to answer draws in.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/reasoning-tree
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/reasoning-tree

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { ReasoningTree } from "@/components/xzero/reasoning-tree/reasoning-tree";

export function SearchExplainer() {
  return (
    <ReasoningTree
      question="Which caching plan cuts p95 latency?"
      defaultBeamWidth={2}
      onAnswer={({ answer }) => console.log(answer.label, answer.score)}
      thoughts={[
        { label: "Cache at the edge", score: 0.81, text: "Serve product pages from the CDN with a 60 second TTL.", children: [
          { label: "Purge on publish", score: 0.77, children: [
            { label: "Tag based purge", score: 0.9 },
            { label: "Purge everything", score: 0.42 },
          ] },
          { label: "Stale while revalidate", score: 0.84 },
        ] },
        { label: "Add a Redis layer", score: 0.66 },
        { label: "Bigger database", score: 0.35 },
      ]}
    />
  );
}

API reference

ReasoningTree

An illustration of tree search over thoughts. A question proposes candidate thoughts; each gets a score bar that fills, the weakest fade while their edges retract into the parent, and the best few expand another depth, up to three. At the end the best path from the question to the answer draws in the accent with a shimmer travelling along it, and the answer settles in with a check. Play, pause, step and restart drive the search, and a beam width control from 1 to 3 changes how many thoughts survive each depth. The scores are illustrative sample values, not the output of a real model.

PropTypeDefaultDescription
questionstring"Which release plan ships by Friday?"Short question on the root node. Keep it to about three short lines.
questionDetailstring–The full question, shown on hover and focus and read to screen readers. Defaults to the question.
thoughtsReasoningThought[]sample release planThoughts at the first depth, each { id?, label, text?, score?, children? }. label is the short node text (about 2 to 4 words), text the full thought, score an illustrative value from 0 to 0.99. The tree is read to a depth of 3.
beamWidthnumber–How many thoughts survive each depth, from 1 to 3. Controlled; pair it with onBeamWidthChange.
defaultBeamWidthnumber2Starting beam width when uncontrolled.
onBeamWidthChange(beamWidth: number) => void–Called when the beam width control changes. A new width starts the search over.
seednumber7Seeds the scores of thoughts that have none, so the same tree and seed always search the same way.
autoPlaybooleantrueStarts the search the first time the tree scrolls into view. Ignored under reduced motion, which shows the answer.
loopbooleanfalseStarts over about four seconds after the answer is found.
speednumber1Multiplies the pace. At 1 a three depth search takes about 7 seconds; 0 holds still.
controlsbooleantrueShows play and pause, step, restart and the beam width control.
model{ name: string; mark?: ReactNode } | nullClaude Opus 5.5 with the Claude markThe model named in the header. Pass null to show only the title.
titlestring"Tree of thoughts"Header title, shown after the model name.
accentstring"var(--series-1)"Color of kept thoughts and the best path. The answer always uses the success color with a check.
onAnswer(result: { answer, path, beamWidth }) => void–Called once each time the search reaches its answer, with the answer thought and the path from the first depth to it.
classNamestring–Class on the root element.
styleCSSProperties–Inline style on the root element. Set --rt-accent here to recolor the path.

Keyboard interactions

KeysAction
TabMoves to the tree (one stop on the current thought), then play or pause, step, restart and the beam width control.
Arrow up / Arrow downIn the tree, moves to the previous or next thought at the same depth on wide layouts, or the previous or next line of the outline on phones.
Arrow right / Arrow leftMoves to a thought's best shown child, or back to its parent.
Home / EndMoves to the question, or to the answer once it is found.
Arrow left / Arrow right on the beam widthChanges the beam width, which starts the search over.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in illustrations

Guidance for AI tools

Reasoning tree: An illustration of tree search over thoughts: candidates are scored, weak branches fade, the best expand, and the winning path from question to answer draws in. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components