---
title: "Tool Approval"
description: "Hold to let an agent run a tool."
documentation: "https://beui.dev/react-native/tool-approval"
markdown: "https://beui.dev/react-native/tool-approval.md"
---

# Tool Approval

> Hold to let an agent run a tool.

React Native component for Expo, from beUI Native. Group: AI agents. Variants: 1.

## Install

Set up beUI Native once per app first: https://beui.dev/docs/native-setup.md

```bash
npx beui-native add tool-approval
```

Or copy the source by hand and install its libraries:

```bash
npx expo install react-native-reanimated react-native-svg react-native-worklets
npm install uniwind tailwindcss
```

## Links

- Source: https://github.com/starc007/beui-native/tree/main/src/components/tool-approval
- Registry JSON with every file: https://beui.dev/native/r/tool-approval
- Open in Expo Go: exp://u.expo.dev/93a3a95c-6dc2-4adb-b57c-efbecf859f25/--/tool-approval?runtime-version=exposdk%3A58.0.0&channel-name=production
- Web version: https://beui.dev/components/agents/tool-approval.md

## README

### Tool Approval

Native port of [beUI Tool Approval](https://beui.dev/components/agents/tool-approval): asks before an agent runs a tool, then follows the run to its result.

```tsx
import { ToolApproval, ToolApprovalCode } from "./src";

<ToolApproval
  tool="terminal.run"
  title="Run the test suite?"
  description="The agent wants to run the accessibility tests."
  parameters={[{ id: "command", label: "Command", value: <ToolApprovalCode code="bun test" /> }]}
  status={status}
  result="49 tests passed in 2.1s."
  onApprove={allow}
  onAlwaysAllow={allowAlways}
  onDeny={deny}
/>
```

#### Layout

- A quiet top line holds the tool's name and where the run is ("Approval required", "Running", "Completed"), with a matching icon. The status rolls as it changes.
- The title and description span the card. `parameters` sit behind "View details", each label above its value; `ToolApprovalCode` sets commands in monospace.
- "Allow once" spans the card, with "Always allow" (when you pass `onAlwaysAllow`) and "Deny" sharing the row beneath it.

#### Behavior

- You move `status` forward: `approving`, `approved`, `running`, then `complete` or `error`; or `denied`. Once you decide, the details fold away and the actions leave.
- While approving or running, a thin bar slides along the card's bottom edge.
- When the run ends, `result` appears in the card: green for `complete`, red for `error`, neutral for `denied`. The card tells the whole story, not just the request.

#### Risk

`risk` sets how careful allowing is:

- `low`: a tap allows.
- `normal` (the default): allowing takes a 600 ms press and hold.
- `high`: a 900 ms hold, a red-tinted card and Allow button, and `riskNote` explaining why, such as "Deletes files. This can't be undone."

`confirm` and `holdDuration` override these.

#### Better on a phone

- The hold means a stray thumb can't run a tool. A fill sweeps across the button while you hold and drains back if you let go early. The label coaches you: "Keep holding…" while pressed, "Hold to allow" after a tap that let go too soon.
- The actions are full width and 46 points tall, easy to hit with a thumb.
- The card follows the run to its result instead of handing off to another component.

#### Accessibility

- Screen reader users allow with a double tap; the button's hint says to press and hold.
- The status line is a polite live region, and the card is marked busy while approving or running.
- Reduced motion, or `disableAnimation`, folds without movement, holds the spinner still and shows the running bar as a static tint. The hold fill still shows progress.

Copy this directory, `primitives/running-bar.tsx`, `hooks/use-presence.ts`, `hooks/use-reduced-motion.ts`, `primitives/agent-icons.tsx`, `primitives/disclosure.tsx`, `primitives/roll-text.tsx`, `primitives/spin-glyph.tsx`, `styles/motion.ts`, and the semantic tokens in `styles/theme.css`. It uses `react-native-svg` for its icons.
