Skip to main content
Clever Ops

HITL Approval Card

Human-in-the-loop approval for a pending agent action, plain-language summary, honest risk chip, expandable raw-payload mono block, and allow-once / always-allow / deny callbacks.

Preview & code

Loading HITL Approval Card preview

Installation

pnpm dlx shadcn@latest add @cleverui/hitl-approval-card

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { HitlApprovalCard } from '@/components/ui/hitl-approval-card'
Exampletsx
'use client'

import { useCallback, useState } from 'react'
import {
  HitlApprovalCard,
  type HitlState,
} from '@/components/ui/hitl-approval-card'

const PAYLOAD = `{
  "amount": 124000,
  "currency": "usd",
  "customer": "cus_AcmeLog9k2",
  "reason": "requested_by_customer",
  "metadata": {
    "invoice": "inv_2026_03_8841",
    "agent": "meridian-ops"
  }
}`

export default function HitlApprovalCardDemo() {
  const [state, setState] = useState<HitlState>('pending')

  const resolve = useCallback((next: HitlState) => {
    // brief beat so the press settle reads before the receipt
    window.setTimeout(() => setState(next), 280)
  }, [])

  return (
    <div className="mx-auto flex min-h-[520px] w-full max-w-lg flex-col justify-center px-4 py-12 sm:px-6 sm:py-16">
      <HitlApprovalCard
        action="Issue a $1,240 refund to Acme Logistics"
        tool="stripe.refunds.create"
        rationale="Invoice inv_2026_03_8841 was double-charged on the March close pack; customer ops confirmed the duplicate in Xero."
        risk="medium"
        payload={PAYLOAD}
        state={state}
        onAllowOnce={() => resolve('allowed')}
        onAllowAlways={() => resolve('allowed')}
        onDeny={() => resolve('denied')}
      />
      {state !== 'pending' && (
        <button
          type="button"
          onClick={() => setState('pending')}
          className="mt-6 self-center font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden"
        >
          Reset demo
        </button>
      )}
    </div>
  )
}

API reference

HitlApprovalCard accepts the following props.

PropTypeDefaultDescription
action*stringplain-language summary of what the agent wants to do
toolstringmono tool identifier, e.g. 'stripe.refunds.create'
rationalestringone muted sentence: why the agent proposes this
riskHitlRisk'low'risk chip treatment; high uses the destructive token
payloadstringraw request payload (JSON string) rendered verbatim
stateHitlState'pending'resolution is prop-driven; buttons only fire callbacks
onAllowOnce() => void
onAllowAlways() => void
onDeny() => void

…plus everything from Omit< React.HTMLAttributes<HTMLElement>, 'onDrag' | 'onDragStart' | 'onDragEnd' | 'onAnimationStart' >: className, event handlers, aria attributes and the rest pass straight through.

Referenced types

Typestsx
export type HitlRisk = 'low' | 'medium' | 'high'

export type HitlState = 'pending' | 'allowed' | 'denied'

Frequently asked questions

How do I install the HITL Approval Card component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/hitl-approval-card`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does HITL Approval Card require?

HITL Approval Card uses motion and lucide-react on top of React and Tailwind CSS. You don't need to install them manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme HITL Approval Card to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services