Skip to content

ConversionBreakdown

Amount → fee → rate → recipient gets. Every line.
Implemented
Status
Implemented
Family
4 of 13
Registry
@lopifi/conversion-breakdown
npx shadcn@latest add @lopifi/theme @lopifi/conversion-breakdown

The component, rendering

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

Preview

The four-layer spec

Wise's honesty pattern, as a component. Every line visible.

Amount to convert                    1,000.00 USD
Our fee                                 −4.50 USD   ← itemized, named
Amount we'll convert                   995.50 USD
                                      ──────────    ← single rule
Rate  1 USD = 0.91842 EUR  · 09:12 UTC
Recipient gets                         914.29 EUR
                                      ══════════    ← double rule
  • Every fee named and itemized. Never a lump "Fees".
  • The rate line carries its timestamp.
  • Uses Rule — the same grammar as the statements, which is what makes the library feel like one system.
  • Percentage-of-total splits use largest-remainder allocation, so the parts sum to the total exactly.

Lifted verbatim from Swaps & FX. 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/conversion-breakdown.tsx

Lopifi dependencies · 11
as-ofcnfiscal-periodformat-moneymoneymoney.typesrate-lineruletooltipuse-live-valueuse-shared-now
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/conversion-breakdown.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/conversion-breakdown.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 { RateLine } from "@/components/ledger/rate-line";
import { Rule } from "@/components/ledger/rule";

export interface ConversionBreakdownProps extends React.ComponentPropsWithoutRef<"div"> {
  amount: MoneyValue;
  converted: MoneyValue;
  /** Every fee named and itemized. Never a lump "Fees". */
  fees: { label: string; amount: MoneyValue }[];
  from: string;
  rate: number;
  rateAsOf: Date;
  recipientGets: MoneyValue;
  to: string;
}

/** The honesty pattern, as a component. Every line visible. */
export const ConversionBreakdown = React.forwardRef<HTMLDivElement, ConversionBreakdownProps>(
  ({ className, amount, fees, converted, from, to, rate, rateAsOf, recipientGets, ...props }, ref) => (
    <div className={cn("w-full", className)} ref={ref} {...props}>
      <table className="w-full">
        <caption className="sr-only">Conversion breakdown</caption>
        <tbody>
          <Line amount={amount} label="Amount to convert" showCode />
          {fees.map((f) => (
            <Line amount={f.amount} key={f.label} label={f.label} negative showCode />
          ))}
          <tr>
            <td />
            <td className="py-1">
              <Rule variant="subtotal" />
            </td>
          </tr>
          <Line amount={converted} emphasis label="Amount we’ll convert" showCode />
          <tr>
            <th className="pt-3 text-left" colSpan={2} scope="row">
              <RateLine asOf={rateAsOf} from={from} rate={rate} to={to} />
            </th>
          </tr>
          <Line amount={recipientGets} emphasis label="Recipient gets" showCode size="md" />
          <tr>
            <td />
            <td className="pt-1">
              <Rule variant="total" />
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  ),
);
ConversionBreakdown.displayName = "ConversionBreakdown";

function Line({
  label,
  amount,
  showCode,
  emphasis,
  negative,
  size = "sm",
}: {
  label: string;
  amount: MoneyValue;
  showCode?: boolean;
  emphasis?: boolean;
  negative?: boolean;
  size?: "sm" | "md";
}) {
  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}
      </th>
      <td className="py-1 text-right">
        <Money
          showCode={showCode}
          size={size}
          value={negative ? { ...amount, amount: -Math.abs(Number(amount.amount)) } : 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 Swaps & FX

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 ConversionBreakdown 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 Swaps & FX 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.