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
- ProPro · unlocked
- 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
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.
| Type | Notes | ||
|---|---|---|---|
question | string | Yes | – |
context | string | No | Why the agent is asking. |
options | DecisionOption[] | Yes | – |
recommended | string | No | The option the agent would pick. Shown, never pre-selected. |
reason | string | No | – |
onChoose | (choice: DecisionChoice) => void | Promise<void> | No | Sends the choice back. May return a promise. |
allowCustom | boolean | No | Allow a written answer instead of a branch. Default true. |
agent | string | No | – |
model | string | No | The model behind the agent, shown under its name: "Opus 4.5". |
icon | React.ReactNode | No | The agent's logo, supplied by you. |
waitingSince | Date | number | No | When the agent started waiting, for the clock. |
look | Look | No | – |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themebuttonStates
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