SwapRoute
- Status
- Implemented
- Family
- 4 of 13
- Registry
- @lopifi/swap-route
npx shadcn@latest add @lopifi/theme @lopifi/swap-routeThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
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
- 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.
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
- SwapWidgetFrom/to with the flip. The signature component.
- RateLineA rate with its timestamp. Never one without the other.
- RateLockLocked rate with a countdown and expiry behavior.
- ConversionBreakdownAmount → fee → rate → recipient gets. Every line.
- CurrencyPairChartRate history with a period selector.
- RateTickerLive multi-pair ticker with value flash.
- SlippageControlTolerance setting with an explicit worst case.
- FxExposurePosition by currency with unrealized gain/loss.
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.
- SwapRoute, runningThe swaps showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Swaps & FXThe governing rule for this entire family: A rate is a perishable fact. It never appears without a timestamp, and it is never transacted on without a lock. Specs for 9 React components: SwapWidget, RateLine, RateLock, ConversionBreakdown and 5 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 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.