Skip to content

ConfirmPaymentDialog

Amount, destination, timing. Hold-to-confirm.
Implemented
Status
Implemented
Family
3 of 13
Registry
@lopifi/confirm-payment-dialog
npx shadcn@latest add @lopifi/theme @lopifi/confirm-payment-dialog

The component, rendering

Real data, the shipped component. Switch the theme to check the claims the spec makes below.

Preview

The four-layer spec

Amount, destination, timing. In that order. Every time.

Send $12,400.00 to Northwind Ltd?
To account ••••4291 · Arrives 8 Sep
This can't be undone once submitted.
[Cancel]  [Hold to send →]

AlertDialog. Focus lands on Cancel, never on the destructive action. Escape cancels.

For irreversible movements — wires, ACH past cutoff — the confirm is hold-to-confirm (1500ms linear fill, 200ms release). Slow where the user is deciding. Full spec including the keyboard and typed-confirmation fallbacks in motion catalog — this can never be the only path, because gating money behind a motor-skill requirement is an accessibility failure.

Lifted verbatim from Payments. The doc and this page are the same paragraphs, so they cannot disagree.

What lands in your repository

One component is never one file. Everything below is copied into your project, where you own it.

Files

components/ledger/confirm-payment-dialog.tsx

Lopifi dependencies · 11
buttoncnfiscal-periodformat-moneyhold-to-confirmiconsmoneymoney.typesreferencetooltipuse-media-query
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/confirm-payment-dialog.json

The whole component

No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.

components/ledger/confirm-payment-dialog.tsx
"use client";

import { Dialog } from "@base-ui-components/react/dialog";
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { formatDate } from "@/lib/ledger/fiscal-period";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { Button } from "@/components/ledger/button";
import { HoldToConfirm } from "@/components/ledger/hold-to-confirm";
import { Money } from "@/components/ledger/money";
import { MaskedAccount } from "@/components/ledger/reference";

export interface ConfirmPaymentDialogProps {
  amount: MoneyValue;
  arrivalDate: Date;
  /** Wires and post-cutoff ACH: irreversible, so hold-to-confirm. */
  irreversible?: boolean;
  onConfirm: () => void;
  onOpenChange: (open: boolean) => void;
  open: boolean;
  payeeLast4: string;
  payeeName: string;
}

/**
 * Amount, destination, timing. In that order. Every time.
 *
 * Focus lands on Cancel, never on the destructive action. Escape cancels.
 */
export function ConfirmPaymentDialog({
  open,
  onOpenChange,
  amount,
  payeeName,
  payeeLast4,
  arrivalDate,
  irreversible = true,
  onConfirm,
}: ConfirmPaymentDialogProps) {
  const cancelRef = React.useRef<HTMLButtonElement>(null);

  return (
    <Dialog.Root onOpenChange={onOpenChange} open={open}>
      <Dialog.Portal>
        <Dialog.Backdrop className="fixed inset-0 z-overlay bg-[oklch(0.21_0.02_265/0.4)] data-[open]:animate-[ledger-enter_240ms_var(--ease-out)]" />
        <Dialog.Popup
          className={cn(
            // Dialogs stay centred. No transform-origin games.
            "fixed left-1/2 top-1/2 z-dialog w-[calc(100vw-32px)] max-w-[420px]",
            "-translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-surface-raised p-6",
            "shadow-elevation-4 outline-none",
            "data-[open]:ledger-enter",
          )}
          /* Money leaves the building here: focus lands on Cancel. */
          initialFocus={cancelRef}
          role="alertdialog"
        >
          <Dialog.Title className="text-title-md font-medium">
            Send <Money className="align-baseline" size="md" value={amount} /> to {payeeName}?
          </Dialog.Title>
          <Dialog.Description className="mt-2 space-y-1 text-body text-text-secondary" render={<div />}>
            <p className="flex items-center gap-1">
              To account <MaskedAccount last4={payeeLast4} /> · Arrives {formatDate(arrivalDate)}
            </p>
            {irreversible ? <p className="text-text-primary">This can’t be undone once submitted.</p> : null}
          </Dialog.Description>

          <div className="mt-6 flex flex-col gap-3">
            {irreversible ? (
              <HoldToConfirm
                label={`Hold to send ${plain(amount)}`}
                onConfirm={() => {
                  onConfirm();
                  onOpenChange(false);
                }}
                typedConfirmation="SEND"
              />
            ) : (
              <Button
                onClick={() => {
                  onConfirm();
                  onOpenChange(false);
                }}
                variant="primary"
              >
                Send {plain(amount)}
              </Button>
            )}
            <Dialog.Close render={<Button ref={cancelRef} variant="secondary" />}>Cancel</Dialog.Close>
          </div>
        </Dialog.Popup>
      </Dialog.Portal>
    </Dialog.Root>
  );
}

function plain(value: MoneyValue) {
  return new Intl.NumberFormat("en-US", {
    currency: value.currency,
    currencyDisplay: "narrowSymbol",
    style: "currency",
  }).format(Number(value.amount) / 10 ** (value.scale ?? 2));
}

The accounting it encodes

Concepts this component renders. Each one is defined once, in the lexicon, and used identically in the code and the copy.

Also in Payments

See also

A component is specified in one place, defined in another, and running in a third. All three, from here.

Elsewhere in the system

Where ConfirmPaymentDialog sits in the rest of the system — the live section it renders in, the calculators that compute what it displays, and the ledger payloads it is fed from.

Components are copied into your repository and meant to be edited — rounding policy, fiscal calendar and compliance copy differ per company.

Told when Payments changes

Components are copied into your repo, so a fix here does not reach you on its own. One email when a component in this family changes in a way that needs a migration — and nothing when it does not.

One address, no list rental, unsubscribe in one click.

Works in your QuickBooks Online or Xero file

Get your books closed every month

Lopifi is building AI bookkeeping that keeps your books closed on US GAAP as transactions happen, with a CPA review every quarter, for $200 a month. We’re not open yet.

$200/month when we open. No card now.