CheckoutSummary
- Status
- Implemented
- Family
- 3 of 13
- Registry
- @lopifi/checkout-summary
npx shadcn@latest add @lopifi/theme @lopifi/checkout-summaryThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Line items → subtotal (single rule) → fees → tax → total (double rule). Uses the same Rule grammar as the statements. Fees are itemized and named, never a lump "Fees". Multi-currency lines show conversion with the rate and its timestamp.
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/checkout-summary.tsx
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/checkout-summary.json
The whole component
No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { Money } from "@/components/ledger/money";
import { Rule } from "@/components/ledger/rule";
export type SummaryLine = { label: string; amount: MoneyValue; note?: string };
export interface CheckoutSummaryProps extends React.ComponentPropsWithoutRef<"div"> {
/** Itemized and named, never a lump "Fees". */
fees?: SummaryLine[];
items: SummaryLine[];
roundingNote?: string;
subtotal: MoneyValue;
tax?: SummaryLine[];
total: MoneyValue;
}
/**
* Line items → subtotal (single rule) → fees → tax → total (double rule).
* The same `Rule` grammar as the statements, which is what makes the
* library read as one system.
*/
export const CheckoutSummary = React.forwardRef<HTMLDivElement, CheckoutSummaryProps>(
({ className, items, subtotal, fees = [], tax = [], total, roundingNote, ...props }, ref) => (
<div className={cn("w-full", className)} ref={ref} {...props}>
<table className="w-full">
<caption className="sr-only">Order summary</caption>
<tbody>
{items.map((line) => (
<Line key={line.label} {...line} />
))}
<tr>
<td />
<td className="py-1">
<Rule variant="subtotal" />
</td>
</tr>
<Line amount={subtotal} emphasis label="Subtotal" />
{fees.map((line) => (
<Line key={line.label} {...line} />
))}
{tax.map((line) => (
<Line key={line.label} {...line} />
))}
<tr>
<td />
<td className="py-1">
<Rule variant="subtotal" />
</td>
</tr>
<tr>
<th className="py-1 text-left text-body font-medium" scope="row">
Total
</th>
<td className="py-1 text-right">
<Money accounting size="md" value={total} />
</td>
</tr>
<tr>
<td />
<td className="pt-1">
<Rule variant="total" />
</td>
</tr>
</tbody>
</table>
{roundingNote ? <p className="mt-2 text-caption text-text-tertiary">† {roundingNote}</p> : null}
</div>
),
);
CheckoutSummary.displayName = "CheckoutSummary";
function Line({ label, amount, note, emphasis }: SummaryLine & { emphasis?: boolean }) {
return (
<tr>
<th
className={cn(
"py-1 pr-6 text-left text-body font-normal",
emphasis ? "font-medium text-text-primary" : "text-text-secondary",
)}
scope="row"
>
{label}
{note ? <span className="block text-caption text-text-tertiary">{note}</span> : null}
</th>
<td className="py-1 text-right align-top">
<Money accounting value={amount} />
</td>
</tr>
);
}
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
- AmountInputThe hardest input in fintech.
- CurrencySelectSearchable, with recents.
- PayeeSelectRecipient picker with fuzzy search and last-paid.
- PaymentFormAmount → payee → method → date → memo.
- PaymentMethodListSelectable method cards.
- ConfirmPaymentDialogAmount, destination, timing. Hold-to-confirm.
- PaymentStatusTimelineSubmitted → sent → settled, with real timestamps.
- PaymentSuccessThe sanctioned delight moment.
- ReceiptSheetPrintable/shareable receipt.
- PayoutScheduleUpcoming payouts calendar.
- CardInputPAN / expiry / CVC with correct autocomplete.
- BankAccountInputRouting + account with checksum validation.
- RecurringScheduleFrequency, end condition, preview of next 3.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Payments — the family specThe four-layer specification this component was built against, before it was written.Doc
- Payment forms, methods and receiptsThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- StatementP&L, balance sheet, or cash flowTerm
Elsewhere in the system
Where CheckoutSummary 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.
- CheckoutSummary, runningThe payments showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- VAT / sales taxGross to net is a division, not a multiplication. The three figures always add back up.Tool
- Amount in wordsFor the check, the note, the contract schedule — with the cents as a fraction over 100.Tool
- Items, products and servicesIs an item optional, required, or a subsystem?API
- TaxWho computes the tax, and can you override it?API
- PaymentsPayments — specs for 14 React components: AmountInput, CurrencySelect, PayeeSelect, PaymentForm and 10 more.Doc
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.