Docs menu

Guides


Primitives
Forms
Layout
Feedback
Overlays
Navigation
Data Display
AI

Tool Approval

The prompt an agent shows before it runs a tool: which tool, what it will do, and Approve / Deny, with an optional "Always allow". It's a<section role="group"> named by its own real heading, rather than a landmark region, because a long transcript can hold dozens of these and a region each would flood the landmark list. Once it's approved, follow it with a Tool Call for the run itself.

Allow bash to run?

Run the test suite in the repository root.

sh
bun run test -- --run

After a decision

The buttons are replaced by a status line inside arole="status" live region. The region is in the page from the start, empty while pending, because a live region only announces changes made after it exists. If focus was on the button that just disappeared, it moves to the status line instead of falling back to the page. The footer keeps the same height either way, so the decision doesn't shift the transcript below it.

Examples

Approved

A decided prompt, as it stays in the transcript.

Allow read_file to run?

Read src/auth.ts

Usage
<ToolApproval tool="read_file" status="approved">
  <p>Read src/auth.ts</p>
</ToolApproval>

Denied

Status text is overridable through labels.

Allow bash to run?

rm -rf node_modules

Usage
<ToolApproval
  tool="bash"
  status="denied"
  labels={{ denied: "Skipped by you" }}
>
  <p>rm -rf node_modules</p>
</ToolApproval>

Playground

Toggle every adjustable prop and watch the component — and the code — update live.

Allow github.create_issue to run?

Open an issue titled “Flaky upload test” in kernel-ui.

Unstyled

Same component — Kernel look stripped. See Platforms.

status
onAlwaysAllow
Usage
<ToolApproval
  tool="github.create_issue"
  onApprove={run}
  onDeny={skip}
  onAlwaysAllow={allowForSession}
>
  <p>Open an issue titled “Flaky upload test” in kernel-ui.</p>
</ToolApproval>

Props

Props for Tool Approval.
PropTypeDefault
toolReactNode (required)—
titleReactNode"Allow tool to run?"
headingLevel1 | 2 | 3 | 4 | 5 | 63
status / defaultStatus"pending" | "approved" | "denied""pending"
onStatusChange(status) => void—
onApprove / onDeny() => void—
onAlwaysAllow() => void (adds the button)—
labelsPartial<{ approve, deny, alwaysAllow, approved, alwaysAllowed, denied }>English defaults
childrenReactNode (summary, arguments)—

The custom element fires bubbling, cancelable approve,deny and always-allow events, then sets its own status attribute unless a listener callspreventDefault(). Text overrides are attributes:approve-label, deny-label,always-allow-label, approved-label,always-allowed-label, denied-label.

Accessibility

  • The group's name is its heading, so "Allow bash to run?" is announced when focus enters the buttons.
  • Actions are real <button>s; the decision is announced politely through role="status".
  • Focus is never dropped to <body> when the buttons are removed.