Rendyn

Component library

189 components

Agent UI

Approval Card

Approval Card presents a decision or a sequence of questions inside an agent interface. The parent controls the decision status; the component does not authorize an action or persist a review.

React Tailwind CSS

Practical React example

Ask a reviewer to accept or reject one proposed copy change. Keep the card in submitting state until the application confirms that the decision was recorded, then show the recorded outcome.

Before you copy and paste

Copy every returned file, including the approval-card types, disclosure, button, input, selection and motion helpers. The onDecision function below must call your application’s authorized decision endpoint and reject if the decision is not confirmed.

Listed package dependencies: clsx, lucide-react, motion, react, tailwind-merge.

Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.

Record an asynchronous decision before showing success

'use client';

import { useRef, useState } from 'react';
import { ApprovalCard, type ApprovalCardStatus } from '@/components/agents/approval-card';

type Decision = 'approved' | 'rejected';

export function ReviewDecision({ onDecision }: {
  onDecision: (decision: Decision) => Promise<void>;
}) {
  const [status, setStatus] = useState<ApprovalCardStatus>('pending');
  const [error, setError] = useState('');
  const busy = useRef(false);

  async function decide(decision: Decision) {
    if (busy.current) return;
    busy.current = true;
    setStatus('submitting');
    setError('');
    try {
      // Resolve only after your server has authorized and recorded the decision.
      await onDecision(decision);
      setStatus(decision);
    } catch {
      setStatus('pending');
      setError('The decision could not be saved. Check its status before retrying.');
    } finally {
      busy.current = false;
    }
  }

  return (
    <section aria-label="Review the proposed change" className="max-w-lg">
      <ApprovalCard
        title="Apply the proposed copy change?"
        description="Review the wording before recording your decision."
        status={status}
        onApprove={() => { void decide('approved'); }}
        onReject={() => { void decide('rejected'); }}
      >
        <p>Change the button label from “Continue” to “Save draft”.</p>
      </ApprovalCard>
      {error && <p role="alert">{error}</p>}
    </section>
  );
}

The synchronous ref prevents repeated clicks within one render. The parent supplies persistence through onDecision; the callback must resolve only after an authoritative response. Failures return to pending and show an alert. For an uncertain network outcome, reconcile the existing decision before retrying.

Customization

status
Control pending, submitting, approved, rejected, changes-requested or answered. Clicking Approve does not automatically change this prop or save anything.
onApprove / onReject / onRequestChanges
Callbacks report intent. Pass only the actions your workflow supports, and derive their availability from server-authorized state.
questions / answers / step
Question mode uses questions plus controlled answers and step, or defaultAnswers and defaultStep for local state. In question mode, onSubmit receives the answer record. Validate question IDs and allowed answers on the server.

Integration notes

  • An approval card is not an access-control mechanism. Bind a recorded decision to the authenticated reviewer, exact proposal revision and allowed state transition on the server.
  • The local busy flag only protects this mounted UI from repeated clicks. Use server-side idempotency and conflict handling for reloads, concurrent reviewers and uncertain responses.
  • The imported card does not provide an error status. Keep failures in parent state as shown. Test focus and announcements when the interactive content collapses into the result.

Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.

Better with your agent

Give your agent taste.

The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.

All components are free. Sign up only to connect MCP.

Connect to MCP