# Approval Card

> Asks a person to allow or deny an action before an agent runs it.

```tsx
'use client';

import { useState } from 'react';
import { ApprovalCard } from '@brand-studio/ui';
import type { ApprovalStatus } from '@brand-studio/ui';

export default function ApprovalCardDemo() {
  const [status, setStatus] = useState<ApprovalStatus>('pending');
  return (
    <div style={{ width: '100%', maxWidth: 440 }}>
      <ApprovalCard
        title="Place a reorder?"
        description="The agent wants to buy your usual coffee."
        detail={'orders.create({ item: "ethiopia-guji-250", quantity: 2 })'}
        status={status}
        onApprove={() => setStatus('approved')}
        onReject={() => setStatus('rejected')}
      />
    </div>
  );
}
```

## Installation

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, ApprovalCard } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { ApprovalCard } from '@brand-studio/ui';
```

```tsx
<ApprovalCard
  title="Place a reorder?"
  status={status}
  onApprove={() => setStatus('approved')}
  onReject={() => setStatus('rejected')}
/>
```

## Accessibility

- Deny comes first and Allow is the primary action, so the keyboard reaches the safe choice first.
- After a decision the buttons give way to the outcome, announced through a live region.

## API Reference

| Prop | Type | Default |
|---|---|---|
| `title` | `string` | – |
| `description?` | `string` | – |
| `detail?` | `React.ReactNode` | – |
| `status?` | `"approved" \| "pending" \| "rejected"` | `'pending'` |
| `onApprove?` | `(() => void)` | – |
| `onReject?` | `(() => void)` | – |
| `approveLabel?` | `string` | `'Allow'` |
| `rejectLabel?` | `string` | `'Deny'` |
| `className?` | `string` | `''` |

Source: https://brandstudio.js.org/docs/components/approval-card/
