Skip to main content

Confirmation

An interactive tool-approval gate built on Kinetic Button with spring height adaptation, directional branch swaps, stroke-drawn checks, and rejection shake.

@heroicons/react
Approve cleanup_cache execution?

Deletes 14 stale build artifacts inside the local cache directory.

Customize

Speed0.45
Blur reveal (px)8

Installation

npx shadcn@latest add @kinetic/confirmation

Usage

Compose Confirmation, ConfirmationTitle, ConfirmationRequest, ConfirmationAccepted, ConfirmationRejected, ConfirmationActions, and ConfirmationAction.

import {
  Confirmation,
  ConfirmationAccepted,
  ConfirmationAction,
  ConfirmationActions,
  ConfirmationRejected,
  ConfirmationRequest,
  ConfirmationTitle,
  type ConfirmationApproval,
  type ConfirmationState,
} from "@/components/kinetic/ui/confirmation";

interface ApprovalGateProps {
  readonly state: ConfirmationState;
  readonly approval: ConfirmationApproval;
  readonly onApprove: () => void;
  readonly onReject: () => void;
}

export function ApprovalGate({ state, approval, onApprove, onReject }: ApprovalGateProps) {
  return (
    <Confirmation state={state} approval={approval}>
      <ConfirmationTitle>Run production migration?</ConfirmationTitle>
      <ConfirmationRequest>
        <p className="text-muted-foreground">Applies two schema changes to the target database.</p>
        <ConfirmationActions>
          <ConfirmationAction variant="outline" onClick={onReject}>
            Reject
          </ConfirmationAction>
          <ConfirmationAction onClick={onApprove}>Approve</ConfirmationAction>
        </ConfirmationActions>
      </ConfirmationRequest>
      <ConfirmationAccepted>Approved. Executing migration.</ConfirmationAccepted>
      <ConfirmationRejected />
    </Confirmation>
  );
}

Approval branching

Confirmation switches automatically between three branches:

  • ConfirmationRequest renders while state is approval-requested.
  • ConfirmationAccepted renders when approval.approved === true (and draws the checkmark via drawStroke).
  • ConfirmationRejected renders with role="alert" when state === "output-denied" or approval.approved === false, falling back to approval.reason when no children are supplied.

Motion preferences

Container height adapts via useAnimatedSize, branch changes animate via directionalSwap (speed: 0.45, blurPx: 8), and rejection triggers a subtle shake. Reduced motion disables motion blur, shakes, and stroke animations cleanly.

API Reference

Confirmation

Zero-dependency approval gate with spring height transitions, directional branch swaps, drawStroke approval check, and rejection shake.

PropTypeDefaultDescription
approval / stateConfirmationApproval / ConfirmationState- / "approval-requested"Approval metadata and current gate state driving active branch.
animated / speed / blurPxboolean / number / numbertrue / 0.45 / 8Enables height spring, directionalSwap, drawStroke, and shake with shared speed and blur.

ConfirmationTitle / ConfirmationRequest / ConfirmationAccepted / ConfirmationRejected / ConfirmationActions / ConfirmationAction

Branch containers animated with directionalSwap, drawStroke checkmark, and Kinetic Button actions.

PropTypeDefaultDescription
icon (ConfirmationAccepted / ConfirmationRejected)React.ReactNode | false-Optional custom status icon or false to hide default icon.
variant / size (ConfirmationAction)KineticButtonVariant / KineticButtonSize"default" / "sm"Kinetic Button style variant and size preset.