<!-- Generated by scripts/gen-docs.mts from the JSDoc in registry/. Do not edit; run `pnpm run docs`. -->

# PermissionPrompt

An agent asking the person's permission before it acts: what it wants to do, exactly what it would run, why, and how risky it is, with Allow once and Deny. Once answered, here or in another app, the buttons give way to one line that says who answered and from where, "Allowed by Ana from their phone", which a screen reader hears; if the person was on a button, focus moves to that line. Allow and Deny are the person's alone: its agent side, `permissionPromptAx`, declares them person-only, so no agent door offers them.

## Install

Once per app, with Tailwind CSS v4 and an `@/*` path alias (skip `init` in an existing shadcn app), then the component:

```sh
npx shadcn@latest init --base base --preset nova --yes --no-monorepo
npx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823
npx shadcn@latest add ourostack/ouro-ui/permission-prompt#v1.3.823
```

More: [Installing](https://ui.ouroboros.bot/docs/installing.md).

```tsx
import { PermissionPrompt } from "@/components/ouro/permission-prompt/permission-prompt";
```

## Example

```tsx
<PermissionPrompt
  title="Your agent wants to run a command"
  detail="npm install left-pad"
  reason="To add the package the importer needs."
  risk="medium"
  onAllow={allow}
  onDeny={deny}
  answer={answer}
/>
```

## Use instead when

- Use `ConfirmDialog` instead to confirm the person's own action in your app, and `AttentionCard` instead to list a request that waits elsewhere.

## Props

Type: `PermissionPromptProps`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `allowLabel` | `string` | `"Allow once"` | The allow button's label. |
| `answer` | `PermissionAnswer` |  | The person's answer, once they have given it, in this app or another: the buttons give way to who answered. |
| `answering` | `"allow" \| "deny"` |  | Which answer is on its way, while your app sends it: that button shows it is busy and neither presses again. |
| `className` | `string` |  | Layout only: margins, width (`mt-2`, `max-w-xl`). Appearance classes warn in development. |
| `denyLabel` | `string` | `"Deny"` | The deny button's label. |
| `detail` | `string` |  | Exactly what it would run or change, as plain text, shown in a CodeBlock: `npm install left-pad`. |
| `headingLevel` | `2 \| 3 \| 4 \| 5 \| 6` | `3` | The title's heading level, one below the section's heading, as Card's. |
| `onAllow` | `(() => void)` |  | Called when the person presses Allow once. |
| `onDeny` | `(() => void)` |  | Called when the person presses Deny. |
| `reason` | `ReactNode` |  | Why it asks, in the agent's words: "To add the package the importer needs." |
| `ref` | `Ref<HTMLDivElement>` |  | Reaches the rendered element. |
| `risk` | `"medium" \| "low" \| "high"` |  | How much could go wrong if the person allows it, as a badge: low, medium or high. |
| `title` (required) | `ReactNode` |  | What the agent wants to do, as a sentence: "Your agent wants to run a command". |

## Don't use

These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.

- `command`: Not a prop. What it would run is `detail`: `<PermissionPrompt detail="npm install">`.
- `description`: Not a prop. Why it asks is `reason`: `<PermissionPrompt reason="To add the package">`.
- `onApprove`: Not a prop. Ouro UI uses `onAllow`: `<PermissionPrompt onAllow={allow}>`.
- `onReject`: Not a prop. Ouro UI uses `onDeny`: `<PermissionPrompt onDeny={deny}>`.
- `status`: Not a prop. The person's answer is `answer`: `<PermissionPrompt answer={{ decision: "allowed", by: "Ana" }}>`.

## `className` is for layout only

Pass margins, width and grid placement (`mt-4`, `w-full`, `col-span-2`).

Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (`hover:`, `sm:`) and any `!` are removed, it starts with `bg-`, `text-`, `border-`, `rounded-`, `shadow-`, `font-`, `ring-`, `from-`, `via-`, `to-`, `fill-` or `stroke-`, or is `border`, `rounded`, `shadow` or `ring`, or has a `dark:` variant. Text wrapping, overflow and table layout classes (`text-wrap`, `text-ellipsis`, `border-collapse`) are layout and do not warn.

Alignment classes (`text-center`) warn too: set alignment on a parent element.

## Types

### `PermissionAnswer`

How the person answered a `PermissionPrompt`.

```ts
interface PermissionAnswer {
  /** What they chose. */
  decision: "allowed" | "denied";
  /** Who answered: "Ana", "you". */
  by: ReactNode;
  /** Where they answered from, such as "the desktop app" or "their phone": "Allowed by Ana from their phone". */
  app?: ReactNode;
  /** When, already formatted ("9:41", `<RelativeTime>`). */
  at?: ReactNode;
}
```
