Currency Transfer
A currency transfer status card — the amount converts in place, steps light up one after another, and the rail runs down as each completes.
Currency Transfer
A currency transfer status card — the amount converts in place, steps light up one after another, and the rail runs down as each completes.
The card shows a cross-currency transfer in progress. Each step — payment received, currency converted, sent to destination bank, and arrival — lights up in sequence with a turning spinner. When a step completes, a rail runs down to the next one and its checkmark draws in. The displayed amount rolls its digits like an odometer when the conversion happens, the currency symbol crossfades, and the status badge updates from "In progress" to "Arrived". The transaction reference at the bottom is copyable with a click.
Installation
Install the component with the Craft-UI Blocks CLI — it drops currency-transfer.tsx into your project and wires up its runtime dependencies:
npx mvpblocks add currency-transferpnpm dlx mvpblocks add currency-transferyarn dlx mvpblocks add currency-transferbunx mvpblocks add currency-transferFile Structure
The CLI saves the component to your project's components/ui folder:
Import the default export from @/components/ui/currency-transfer. The props type is exported as CurrencyTransferProps, account data as TransferAccount, and status as TransferStatus.
Usage
CurrencyTransfer is a client component and every prop is optional — with no props it renders a demo transfer that completes on its own. Drop it into any dashboard or transaction view:
"use client";
import CurrencyTransfer from "@/components/ui/currency-transfer";
export function TransferCard() {
return <CurrencyTransfer />;
}Pass your own transfer data with from, to, and rate. The card formats amounts according to the locale:
const transfer = {
from: {
amount: 500,
currency: "USD",
symbol: "$",
bank: "Chase",
last4: "4589",
},
to: {
amount: 460,
currency: "EUR",
symbol: "€",
bank: "Deutsche Bank",
last4: "7823",
name: "Lena Fischer",
},
rate: 0.92,
txnId: "TXN-DAB3UL494",
timestamp: "10:45 AM",
};
<CurrencyTransfer
from={transfer.from}
to={transfer.to}
rate={transfer.rate}
txnId={transfer.txnId}
timestamp={transfer.timestamp}
/>Control the status with the status prop. While "processing", the steps animate up to the last one and wait. Change to "completed" or "failed" to finish the flow:
const [status, setStatus] = useState<"processing" | "completed" | "failed">("processing");
useEffect(() => {
// Poll your API or listen to a webhook
const timer = setInterval(async () => {
const result = await fetch(`/api/transfers/${txnId}`);
const data = await result.json();
setStatus(data.status);
}, 2000);
return () => clearInterval(timer);
}, [txnId]);
<CurrencyTransfer
from={transfer.from}
to={transfer.to}
status={status}
/>Add a retry handler for failed transfers:
async function handleRetry() {
setStatus("processing");
try {
await fetch("/api/transfers/retry", {
method: "POST",
body: JSON.stringify({ txnId }),
});
} catch (error) {
console.error("Retry failed:", error);
}
}
<CurrencyTransfer
from={transfer.from}
to={transfer.to}
status={status}
onRetry={handleRetry}
/>Customize the locale for number formatting and currency symbols:
<CurrencyTransfer
from={transfer.from}
to={transfer.to}
locale="de-DE"
/>Use className to adjust the card's styling:
<CurrencyTransfer
from={transfer.from}
to={transfer.to}
className="max-w-md shadow-lg"
/>Theming
The card uses zinc tones with semantic status colors. The surface is rounded-2xl bg-white ring-1 ring-zinc-200/80 in light mode, inverting to dark:bg-zinc-900 dark:ring-zinc-800. Primary text is text-zinc-900 (dark:text-zinc-100) and secondary text is text-zinc-500 (dark:text-zinc-400).
The recipient avatar shows their initials in bg-zinc-100 text-zinc-700 (dark:bg-zinc-800 dark:text-zinc-200).
Status badges change color based on the transfer state:
- Processing:
bg-zinc-100 text-zinc-600(dark:bg-zinc-800 dark:text-zinc-300) - Completed:
bg-emerald-500/10 text-emerald-700(dark:bg-emerald-400/10 dark:text-emerald-300) - Failed:
bg-red-500/10 text-red-700(dark:bg-red-400/10 dark:text-red-300)
Step nodes follow the progress:
- Pending: Empty ring in
border-zinc-200(dark:border-zinc-700) - Active: Ring with a turning arc in
text-zinc-900(dark:text-zinc-100) - Done: Filled circle in
bg-zinc-900(dark:bg-zinc-100) with a white checkmark - Failed: Red circle in
bg-red-500with a white X icon
The rail between steps is bg-zinc-200 (dark:bg-zinc-800) with a filled portion in bg-zinc-900 (dark:bg-zinc-100) that runs down as each step completes.
The retry button appears in failed state as bg-zinc-900 text-white hover:bg-zinc-700 (dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-zinc-300).
Animations
- Step progression: Steps light up one at a time with
1.1sintervals. The active step shows a turning spinner that fades in over200msafter the rail arrives. - Rail run: When a step completes, the rail scales from
0to100%over350mswith an ease-in-out curve, flowing down to the next step. - Checkmark draw: The checkmark inside each completed step draws its path over
300mswith an ease-out curve, creating a handwritten effect. - Digit roll: When the currency converts, each digit rolls like an odometer over
550mswith staggered timing — the rightmost digit moves first with30msbetween each column, creating a cascading effect. - Symbol crossfade: The currency symbol crossfades with a
200mstransition, blurring3pxduring the swap to avoid a harsh snap. - Status badge: The status label crossfades in place over
200ms, keeping the badge width stable so the layout doesn't shift. - Step text: When a step becomes active or fails, its title and detail blur in from
2pxover200ms. - Copy confirmation: Clicking the transaction reference swaps the copy icon for a green checkmark over
150ms, then reverts after1.5s. - Failed state: When a transfer fails, the active step's spinner is replaced by a red X, the text changes to "Couldn't complete" and "Refunded to...", and a Retry button fades in after
150ms. - Reduced motion: All animations are disabled via
motion-reduce:transition-noneormotion-reduce:animate-none. Steps remain interactive but transitions happen instantly.
How it works
The component tracks progress through four steps: payment received, currency converted, sent to destination, and arrival. In uncontrolled mode (no status prop), it runs a demo that advances one step every 1.1s until reaching the last step, then completes after another interval.
In controlled mode, the component respects the status prop. While "processing", steps advance automatically up to the "Arriving" step and wait there until the status changes to "completed" or "failed". This lets you integrate real-time status updates from your backend.
The useProgress hook manages how many steps are done. It starts at 1 (payment already received) and increments on a timer while processing. When the status changes to "processing" after a retry, progress resets to 1 to restart the animation sequence.
Each step has four possible states: "pending" (not reached), "active" (currently processing), "done" (completed), or "failed" (encountered an error). The state determines which icon and colors render.
The digit roll uses a custom RollingNumber component that breaks the formatted number into individual characters. Each digit renders as a vertical strip containing "0123456789" in a one-character-tall window with overflow: hidden. The strip translates vertically by -digit × 10% to show the correct number. Non-digit characters (decimal points, commas, spaces) render as plain text. The translation is staggered from right to left with 30ms delays to create the odometer effect.
The currency symbol swap uses a CSS grid where both symbols occupy the same cell (col-start-1 row-start-1). When converted becomes true, the old symbol fades to opacity: 0 and blurs to 3px while the new symbol fades in from the same blur, creating a smooth crossfade without layout shift.
The transaction reference uses the Clipboard API to copy the ID. The copy button toggles between a CopyIcon and CheckIcon via a copied state that resets after 1.5s. Both icons occupy the same grid cell so the swap doesn't shift the button's layout.
The rail animation uses scale-y from 0 to 100% with origin-top, so it grows downward from the completed step toward the next one. The timing is set to complete just before the next step's spinner fades in, creating a continuous flow of progress.
The component injects a <style> element with href and precedence attributes to define the @keyframes for checkmark drawing and text blur-in. React deduplicates this by the href value, so multiple cards on the page share one stylesheet.
Screen readers receive live updates via aria-live="polite" on an <output> element that announces each step's completion, final arrival, or failure. The status badge uses aria-hidden to suppress duplicate announcements, with only the active label exposed.
Props
Prop
Type
TransferAccount Object
Prop
Type
Registry Bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together. Dependencies: lucide-react (for CheckIcon, CopyIcon, RotateCcwIcon, and XIcon).
Contact
If you find any bug or issue, feel free to raise an issue.
Last updated on