Skip to content

CheckoutSummary

Itemized total with fees and tax.
Implemented
Status
Implemented
Family
3 of 13
Registry
@lopifi/checkout-summary
npx shadcn@latest add @lopifi/theme @lopifi/checkout-summary

The component, rendering

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

Preview

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

Lopifi dependencies · 6
cnformat-moneymoneymoney.typesruletooltip
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.

components/ledger/checkout-summary.tsx
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

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 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.

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.