shadcn.io is an independent project built on shadcn/ui
On this page10 sections
Confirmation is the question an agent asks before a tool call runs: a bordered row with the call itself, Run rm -rf dist?, and Deny and Approve. Use it for calls the reader should answer for, ones that delete, spend, send or can't be undone, and let reads and searches run without asking.
There is no Confirmation component to install: the row is an Item with two Buttons. Once the reader answers, it gives way to the call's Tool line.
Installation
Confirmation is a pattern. The command adds the parts it's built from, Item and Button, and the code to copy is the demo's.
Anatomy

Usage
import { TerminalIcon } from "lucide-solid";
import { Button } from "@/components/ui/button";
import {
Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle,
} from "@/components/ui/item";export function Confirmation(props: {
command: string;
onApprove: () => void;
onDeny: () => void;
}) {
return (
<Item size="sm" variant="outline">
<ItemMedia variant="icon">
<TerminalIcon aria-hidden="true" />
</ItemMedia>
<ItemContent>
<ItemTitle>Run {props.command}?</ItemTitle>
<ItemDescription>The command runs in this project.</ItemDescription>
</ItemContent>
<ItemActions>
<Button onClick={props.onDeny} size="sm" variant="outline">
Deny
</Button>
<Button onClick={props.onApprove} size="sm">
Approve
</Button>
</ItemActions>
</Item>
);
}Render it in the agent's message while the call waits, outside the Trace that holds the agent's steps, since it asks something of the reader rather than reporting work.
Accessibility
Item is a plain div with no role, so the demo gives the question's Item the group role, named by its title through aria-labelledby. Deny and Approve are native <button> elements, Deny first in the tab order. Since the agent is waiting on the reader, the demo moves focus to Deny when the question appears, and a screen reader reads the group's name, Run rm -rf dist?, before the button. Answering replaces the question and the focused button with it, so once the reply is in, the demo moves focus to Reset, where your app would focus its message input.
- Tab
- Moves focus to Deny, then to Approve.
- Shift+Tab
- Moves focus to the previous button, or out of the question.
- Enter
- When focus is on Deny or Approve, gives that answer.
- Space
- When focus is on Deny or Approve, gives that answer.
AI SDK
Name the tool in toolApproval on streamText, and its calls stop at approval-requested until the reader answers. A tool's entry can also be a function of the call's input that returns user-approval only for the calls worth asking about. AI SDK 7 moved this here from needsApproval on the tool, which still works but is deprecated.
const runCommand = tool({
description: "Run a shell command in the project.",
inputSchema: z.object({ command: z.string() }),
execute: async ({ command }) => run(command),
});
const result = streamText({
model,
messages: await convertToModelMessages(messages),
tools: { runCommand },
toolApproval: { runCommand: "user-approval" },
});While the part is approval-requested, answer with its approval.id and whether the reader approved.
AI SDK UI has no Solid package, so post the reader's answer to your chat route with the request's id, and let the route run or skip the tool.
The answer moves the part to approval-responded. When the chat sends again, an approved call runs and ends in output-available or output-error, and a denied one ends in output-denied. Each of those is a Tool line.
Migrating from AI SDK Elements
AI SDK Elements is for React. In Solid, start from the demo above: an Item and two Buttons are all there is to Confirmation.
FAQ
Which AI tool calls should ask for confirmation first?
The ones the reader would want to stop: deleting files, running a migration, sending an email, spending money. Reads, searches and anything easy to undo should run without asking, so that a question still means something when it appears.
With the AI SDK, the tool's entry in toolApproval can be a function of the call's input rather than a fixed user-approval. A shell tool can then run git status on its own and ask only about a command that starts with rm.
What should an AI tool approval prompt say?
What will run, in the words that will run it: the command, the address, the amount. Run rm -rf dist? lets the reader judge the call, where Run a command? only asks for their trust.
Put the call in ItemTitle word for word, from the tool's input rather than from the model's summary of it. Use ItemDescription for one line on where it runs or what it touches, as the demo's The command runs in this project does.
What happens after the reader approves or denies a tool call?
The question goes away and the call becomes a line in the agent's trace: Running, then Ran when the output comes back, or Denied. The agent's turn then continues, and its reply says what it did or that it left things alone, as the demo plays out.
The pending question sits outside Trace because it is a prompt for the reader, not a step the agent took. Once answered, it is a step, so its line goes in a Trace like the others.
How do I tell the agent why a tool call was denied?
Pass a reason along with the answer: addToolApprovalResponse takes it next to id and approved, and it reaches the model with the denial. Without one, the agent only learns that the call was refused.
A short text field that appears after Deny works well for this, filled in with what the reader wanted instead, such as delete only the build cache. Leave it optional, so a quick Deny still goes through.
What happens if the reader never answers the confirmation?
Nothing runs. The route's stream ends at the question, and the call stays at approval-requested until an answer is sent.
If the reader sends another message instead, the AI SDK's convertToModelMessages leaves an unanswered request from an earlier turn out of what the model sees, so that call is dropped. Hide Deny and Approve on a question from an earlier turn, so a late click can't answer a call the model no longer knows about. The demo's Reset clears the thread, question and all.
Can the reader approve or deny a tool call with the keyboard?
Yes, since Deny and Approve are buttons: Tab reaches Deny first, then Approve, and Enter or Space presses the one in focus. Deny comes first on purpose, so a hurried Enter on the first button in the row never runs a destructive call.
The demo also moves focus to Deny as soon as the question appears, so the reader can answer without looking for it, and an Enter pressed out of habit denies the call rather than runs it. The Accessibility section covers what a screen reader hears.
Is this the same as the AI SDK Elements Confirmation?
It does the same job without a wrapper. The Elements Confirmation was an Alert with request, accepted and rejected slots, and here it is an Item with two Buttons that gives way to a Trace line once the reader answers.
The Migrating from AI SDK Elements section has a prompt that rebuilds the old file on these parts and keeps its exports, so the code that imports it keeps working.
API Reference
Confirmation has no props of its own. The question is an Item with variant set to outline and size set to sm, holding an ItemMedia, an ItemContent and an ItemActions. Deny and Approve are Buttons with size set to sm, and the line the question becomes is a Trace line.












