Skip to main content

Approval card Pro

What an assistant wants to change, held until the person says yes: the action as a title, each change before and after, and Approve or Cancel, the way Shopify Sidekick and Copilot ask before they act. While it runs the Approve button spins; then the card says Done, Cancelled or what failed, and keeps the buttons away. Use it for anything that can't be taken back (money moving, a message sent); a change that can be undone should just happen, with Undo in a toast.

import { ApprovalCard } from '@patine-ui/pro';
Loading…
<ApprovalCard
  title="Add $50 to Japan in spring"
  description="From your checking account. It shows in the goal right away."
  changes={[{ label: 'Japan in spring', before: '$3,420', after: '$3,470' }]}
  approveLabel="Add $50"
  status={status}
  onApprove={() => {
    setStatus('running');
    setTimeout(() => setStatus('approved'), 1200);
  }}
  onDeny={() => setStatus('denied')}
  style={{ maxWidth: 420 }}
/>

Try the props​

Props
status
design
<ApprovalCard
title="Add $50 to Japan in spring"
changes={changes}
approveLabel="Add $50"
onApprove={approve}
onDeny={deny}
/>

In a chat​

Draw it from Chat's renderToolCall for a tool call whose status is 'approval', and map the call's status to the card's: 'running' → 'running', 'done' → 'approved', 'denied' → 'denied', 'error' → 'error'. See AI chat: tool cards and approvals. The app kit's @kit/ai does it for every write tool.

Something that can't be undone​

destructive draws Approve in the danger color. Name the thing and the amount on the button ("Delete 3 invoices"), not "OK".

Loading…
<ApprovalCard
  icon="trash"
  title="Delete 3 draft invoices"
  changes={[
    { label: 'INV-1042', after: 'Deleted' },
    { label: 'INV-1043', after: 'Deleted' },
    { label: 'INV-1047', after: 'Deleted' },
  ]}
  approveLabel="Delete 3"
  destructive
  onApprove={() => {}}
  onDeny={() => {}}
  style={{ maxWidth: 420 }}
/>

Accessibility​

RoleAnnouncedKeyboard (web)Touch targetReduce motion
A group named by its title and state"Needs your approval: Add $50 to Japan in spring" as it appears (announce); each change as "Japan in spring, from $3,420 to $3,470"Tab to Cancel and Approve, Enter or Space44 pt buttonsNo motion of its own

The buttons say what they do on their own ("Add $50: Add $50 to Japan in spring"), so they make sense out of context. Once answered, the outcome is a status line.

Props​

PropTypeDefaultDescription
titlestring—Required. The action: "Add $50 to Japan in spring".
descriptionstring—Why, or what else happens.
changes{ label, before?, after }[][]Each value before and after; leave before out for something new.
iconIconName'shieldCheck'Beside the title while it waits.
status'pending' | 'running' | 'approved' | 'denied' | 'error''pending''pending' shows the buttons; 'running' spins Approve.
onApprove / onDeny() => void—
approveLabelstring'Approve'
destructivebooleanfalseApprove in the danger color.
errorstring—What failed, with 'error'.
announcebooleantrueSays the request as the card appears.
labelsPartial<ApprovalLabels>Englishapprove, deny, running, approved, denied, failed, request, from, to.
design / theme / style