# Approval

An action an agent wants to take, waiting for a person. Say what it does and what can't be undone; press and hold the brass seal to approve.

- Category: Agents
- Built from: Stamp and seal
- Docs: https://bevel-ui.vercel.app/components/approval
- Import from: `@/components/ui/approval`

## Install

```bash
npx shadcn@latest add @bevel/approval
```

npm dependencies (installed by the CLI): `@base-ui/react`, `cn`.

## Anatomy

```tsx
<Approval onApprove={send} onReject={sendBack}>
  <ApprovalTitle />
  <ApprovalDescription />
  <ApprovalSignatures>
    <ApprovalSignature name="Priya Shah" signed />
  </ApprovalSignatures>
  <ApprovalActions>
    <ApprovalReject />
    <ApprovalSeal />
  </ApprovalActions>
</Approval>
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `Approval` | div (group) | state (pending, approved, rejected), defaultState, onApprove, onReject. Labelled by its title; the outcome is pressed into the card and announced. |
| `ApprovalDescription` | p | What happens and what can't be undone. |
| `ApprovalSignature` | li | A signature line; signed names are written over it. For dual approval. |
| `ApprovalReject` | Button | Send it back. A single press. |
| `ApprovalSeal` | Button | Press and hold (pointer, Enter or Space) for --approval-hold to approve; letting go early springs back. requireHold={false} for a single press. |

## Example: Before an agent sends email

Hold the seal until it presses. Let go early and nothing happens.

```tsx
"use client"

import * as React from "react"
import {
  Approval,
  ApprovalActions,
  ApprovalDescription,
  ApprovalReject,
  ApprovalSeal,
  ApprovalSignature,
  ApprovalSignatures,
  ApprovalTitle,
  type ApprovalState,
} from "@/components/ui/approval"

/** The drafting agent wants to send a redline. Hold the seal to approve it. */
export function ApprovalSend() {
  const [state, setState] = React.useState<ApprovalState>("pending")
  return (
    <div className="flex flex-col items-center gap-4">
      <Approval state={state} onApprove={() => setState("approved")} onReject={() => setState("rejected")}>
        <ApprovalTitle>Send the redline to opposing counsel</ApprovalTitle>
        <ApprovalDescription>
          The drafting agent will email it to j.lee@haleward.com. Sent email can&apos;t be recalled.
        </ApprovalDescription>
        <ApprovalSignatures>
          <ApprovalSignature name="Priya Shah" signed />
          <ApprovalSignature name="You" signed={state === "approved"} />
        </ApprovalSignatures>
        <ApprovalActions>
          <ApprovalReject>Send back</ApprovalReject>
          <ApprovalSeal />
        </ApprovalActions>
      </Approval>
      <button
        type="button"
        disabled={state === "pending"}
        onClick={() => setState("pending")}
        className="h-9 rounded-md border px-3 text-sm font-medium hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:opacity-50"
      >
        Reset
      </button>
    </div>
  )
}
```
