Skip to content

SwapRoute

Multi-hop path visualization.
Implemented
Status
Implemented
Family
4 of 13
Registry
@lopifi/swap-route
npx shadcn@latest add @lopifi/theme @lopifi/swap-route

The component, rendering

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

Preview

The four-layer spec

Multi-hop path (USD → USDC → EUR). Rendered as a horizontal flow, each hop with its own rate and fee. A rare, legitimate use for the isometric flow-diagram treatment — motion explains the mechanism.

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/swap-route.tsx

Lopifi dependencies · 6
cnformat-moneyiconsmoneymoney.typestooltip
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/swap-route.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/swap-route.tsx
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { formatRate } from "@/lib/ledger/format-money";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { ArrowRightIcon } from "@/components/ledger/icons";
import { Money } from "@/components/ledger/money";

export type Hop = { from: string; to: string; rate: number; fee: MoneyValue };

export interface SwapRouteProps extends React.ComponentPropsWithoutRef<"div"> {
  hops: Hop[];
}

/** A horizontal flow, each hop with its own rate and fee. Motion explains the mechanism. */
export const SwapRoute = React.forwardRef<HTMLDivElement, SwapRouteProps>(
  ({ className, hops, ...props }, ref) => (
    <div
      aria-label="Conversion route"
      className={cn("flex flex-wrap items-stretch gap-2", className)}
      ref={ref}
      role="list"
      {...props}
    >
      {hops.map((hop, i) => (
        <React.Fragment key={`${hop.from}-${hop.to}`}>
          <div className="flex-1 rounded-md border border-border bg-surface p-3" role="listitem">
            <p className="reference-numeric text-label font-medium">
              {hop.from} → {hop.to}
            </p>
            <p className="numeric mt-1 text-caption text-text-secondary">{formatRate(hop.rate)}</p>
            <p className="text-caption text-text-secondary">
              Fee <Money showCode size="xs" tone="inherit" value={hop.fee} />
            </p>
          </div>
          {i < hops.length - 1 ? (
            <ArrowRightIcon aria-hidden="true" className="size-4 self-center text-text-tertiary" />
          ) : null}
        </React.Fragment>
      ))}
    </div>
  ),
);
SwapRoute.displayName = "SwapRoute";

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