Place a reorder?
The agent wants to buy your usual coffee.
orders.create({ item: "ethiopia-guji-250", quantity: 2 })'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
pnpm add @brand-studio/uinpm install @brand-studio/uiyarn add @brand-studio/uibun add @brand-studio/uiInstall the peer dependencies
npm install react react-domImport the stylesheet once
import '@brand-studio/ui/styles.css';Wrap your app in a brand theme
import { BrandTheme, ApprovalCard } from '@brand-studio/ui'; import brand from './brand.json'; <BrandTheme palette={brand.tokens} mode="system"> {/* your app */} </BrandTheme>
Usage
import { ApprovalCard } from '@brand-studio/ui';<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 | '' |