SlippageControl
- Status
- Implemented
- Family
- 4 of 13
- Registry
- @lopifi/slippage-control
npx shadcn@latest add @lopifi/theme @lopifi/slippage-controlThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Tolerance setting that always states the worst case in absolute money: "You'll receive at least 910.15 EUR". A percentage alone is not a decision-grade number.
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/slippage-control.tsx
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/slippage-control.json
The whole component
No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.
"use client";
import { cn } from "@/lib/ledger/cn";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { Money } from "@/components/ledger/money";
export interface SlippageControlProps {
className?: string;
onValueChange: (percent: number) => void;
value: number;
/** The worst case, in absolute money. A percentage alone is not decision-grade. */
worstCase: MoneyValue;
}
const PRESETS = [0.1, 0.5, 1];
export function SlippageControl({ value, onValueChange, worstCase, className }: SlippageControlProps) {
return (
<div className={cn("space-y-2", className)}>
<span className="block text-label font-medium text-text-secondary">Slippage tolerance</span>
<div className="flex flex-wrap items-center gap-2">
{PRESETS.map((p) => (
<button
aria-pressed={value === p}
className={cn(
"numeric h-8 rounded-sm border px-3 text-label font-medium",
"transition-colors duration-1 ease-standard",
value === p
? "border-accent bg-accent-subtle text-accent"
: "border-border hover:bg-surface-hover",
)}
key={p}
onClick={() => onValueChange(p)}
type="button"
>
{p}%
</button>
))}
<label className="flex items-center gap-2">
<span className="sr-only">Custom slippage tolerance, percent</span>
<input
className="numeric h-8 w-16 rounded-sm border border-border bg-surface px-2 text-label outline-none focus-visible:border-accent"
inputMode="decimal"
onChange={(e) => onValueChange(Number(e.target.value.replace(/[^\d.]/g, "")) || 0)}
type="text"
value={value}
/>
<span aria-hidden="true" className="text-label text-text-secondary">
%
</span>
</label>
</div>
<p className="text-caption text-text-secondary">
You’ll receive at least <Money showCode size="xs" tone="inherit" value={worstCase} />.
</p>
</div>
);
}
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.
- SwapRouteMulti-hop path visualization.
- 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 SlippageControl 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.
- SlippageControl, 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.