Decision Tree

An agent stuck at a fork lays the whole decision out as a tree: options, the follow-up each one leads to, and the path you pick lit end to end.

PROGet Decision Tree and 168 other Pro components with pro lifetime — Get Pro

Category
AI Agent
Access
Pro
Source
476 lines · one file
States
7 drawn
Added
3 Nov 2026

The decision inside it

Nothing is picked for you

A pre-selected recommendation gets clicked through. The agent's suggestion is marked, but no option is selected until you choose one, and an option that can't be undone is sent with a press-and-hold.

When to use it

Use Decision Tree when an agent reaches a choice with real consequences and needs a person to pick. For a yes/no on one action use Approval Request; to collect many waiting questions use Agent Inbox.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Decision Tree for this.
Install it: npx shadcn@latest add @liro/decision-tree
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/decision-tree.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/agent-decision.tsx
import { DecisionTree, type DecisionOption, type DecisionChoice } from "@/components/ui/decision-tree";

export function AgentDecision({ options, send }: {
  options: DecisionOption[];
  send: (choice: DecisionChoice) => Promise<void>;
}) {
  return (
    <DecisionTree
      agent="Billing agent"
      model="Claude Sonnet 4.5"
      waitingSince={Date.now() - 90_000}
      question="Two customers share one Stripe ID. What should I do?"
      options={options}
      recommended="merge"
      reason="Both accounts have the same owner email and no overlapping invoices."
      onChoose={send}
      allowCustom
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
questionstring Yes–
contextstring NoWhy the agent is asking.
optionsDecisionOption[] Yes–
recommendedstring NoThe option the agent would pick. Shown, never pre-selected.
reasonstring No–
onChoose(choice: DecisionChoice) => void | Promise<void> NoSends the choice back. May return a promise.
allowCustomboolean NoAllow a written answer instead of a branch. Default true.
agentstring No–
modelstring NoThe model behind the agent, shown under its name: "Opus 4.5".
iconReact.ReactNode NoThe agent's logo, supplied by you.
waitingSinceDate | number NoWhen the agent started waiting, for the clock.
lookLook No–

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themebutton

States

All of them are drawn by the component. None is left for you to design.

  • Waiting for you
  • First choice made
  • Path complete
  • Hold to send
  • Own answer
  • Sent
  • Send failed

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances