Currency Transfer
A live international transfer progress card with recipient header, conversion summary, 4-step timeline, and copyable reference ID.
pnpm dlx shadcn@latest add @haze/currency-transfer---
import { ArrowRight, Check, Copy, LoaderCircle, RotateCcw } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface TransferStep {
title: string;
detail: string;
}
interface Props {
recipientName?: string;
recipientBank?: string;
recipientInitials?: string;
sentAmount?: number;
sourceCurrency?: string;
receivedAmount?: number;
targetCurrency?: string;
transactionId?: string;
rateLockedAt?: string;
statusLabel?: string;
completedLabel?: string;
initialStep?: number;
steps?: TransferStep[];
headingLevel?: 2 | 3 | 4;
class?: string;
}
const {
recipientName = "Lena Fischer",
recipientBank = "Deutsche Bank ··7823",
recipientInitials,
sentAmount = 500,
sourceCurrency = "USD",
receivedAmount = 460,
targetCurrency = "EUR",
transactionId = "TXN-DAB3UL494",
rateLockedAt = "Rate locked 10:45 AM",
statusLabel = "In progress",
completedLabel = "Completed",
initialStep = 1,
steps = [
{ title: "Payment received", detail: "From Chase ··4589" },
{ title: "Converted to EUR", detail: "1 USD = 0.9200 EUR" },
{ title: "Sent to Deutsche Bank", detail: "Deutsche Bank ··7823" },
{ title: "Arriving", detail: "Usually within a minute" },
],
headingLevel = 3,
class: className,
} = Astro.props;
const Heading = ({ 2: "h2", 3: "h3", 4: "h4" } as const)[headingLevel];
const computedInitials =
recipientInitials ??
recipientName
.trim()
.split(/\s+/)
.slice(0, 2)
.map((part) => part[0]?.toUpperCase() ?? "")
.join("");
const safeSent = Number.isFinite(sentAmount) && sentAmount >= 0 ? sentAmount : 0;
const safeReceived = Number.isFinite(receivedAmount) && receivedAmount >= 0 ? receivedAmount : 0;
const clampedStep = Math.max(0, Math.min(steps.length, Math.floor(initialStep)));
const isInitiallyComplete = clampedStep >= steps.length;
const heroMoney = new Intl.NumberFormat("en-US", {
style: "currency",
currency: sourceCurrency,
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(safeSent);
const numFmt = new Intl.NumberFormat("en-US", {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
const conversionSubtitle = `${numFmt.format(safeSent)} ${sourceCurrency} sent · ${numFmt.format(safeReceived)} ${targetCurrency} received`;
---
<section
data-haze-currency-transfer
data-step={String(clampedStep)}
data-total-steps={String(steps.length)}
data-status-active={statusLabel}
data-status-done={completedLabel}
class={cn(
"flex w-full max-w-[360px] min-w-0 flex-col rounded-2xl border border-border bg-card p-5 text-card-foreground shadow-key",
className,
)}
>
<header class="flex items-center justify-between gap-3">
<div class="flex min-w-0 items-center gap-2.5">
<span
aria-hidden="true"
class="grid size-9 shrink-0 place-items-center rounded-full bg-muted text-xs/4 font-semibold text-foreground"
>
{computedInitials}
</span>
<div class="grid min-w-0 gap-0.5">
<Heading class="truncate text-sm/5 font-semibold tracking-tight text-foreground">
{recipientName}
</Heading>
<p class="truncate text-xs/4 text-muted-foreground tabular-nums">{recipientBank}</p>
</div>
</div>
<span
data-transfer-badge
data-complete={isInitiallyComplete ? "" : undefined}
class="inline-flex shrink-0 items-center rounded-full bg-muted px-2.5 py-0.5 text-xs/4 font-medium text-foreground transition-colors duration-200 ease-snappy data-[complete]:bg-success/14 data-[complete]:text-success"
>
{isInitiallyComplete ? completedLabel : statusLabel}
</span>
</header>
<div class="mt-4 flex items-start justify-between gap-2">
<div class="min-w-0">
<p class="text-3xl/9 font-semibold tracking-tight text-foreground tabular-nums">{heroMoney}</p>
<p class="mt-1 text-xs/5 text-muted-foreground tabular-nums wrap-anywhere">{conversionSubtitle}</p>
</div>
<button
type="button"
data-transfer-step-btn
class="hidden h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border border-frame bg-secondary px-3 text-[0.8125rem]/5 font-medium text-foreground transition-[color,background-color,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-100 hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring [[data-haze-currency-transfer][data-enhanced]_&]:inline-flex"
>
<span data-transfer-btn-label>{isInitiallyComplete ? "Replay" : "Advance"}</span>
<ArrowRight
data-transfer-icon-advance
aria-hidden="true"
class={cn("size-3", isInitiallyComplete && "hidden")}
/>
<RotateCcw
data-transfer-icon-replay
aria-hidden="true"
class={cn("size-3", !isInitiallyComplete && "hidden")}
/>
</button>
</div>
<div class="relative mt-5">
<span aria-hidden="true" class="absolute top-3 bottom-3 left-[11px] w-px bg-border"></span>
<ol class="relative grid gap-3.5">
{steps.map((step, index) => {
const state = index < clampedStep ? "done" : index === clampedStep ? "active" : "pending";
return (
<li
data-transfer-step={index}
data-state={state}
data-step-title={step.title}
class="group flex items-start gap-3"
>
<span
aria-hidden="true"
class="relative z-10 mt-0.5 grid size-6 shrink-0 place-items-center rounded-full border border-frame-strong bg-field text-muted-foreground transition-colors duration-200 ease-snappy group-data-[state=done]:border-primary group-data-[state=done]:bg-primary group-data-[state=done]:text-primary-foreground group-data-[state=active]:border-foreground group-data-[state=active]:bg-field group-data-[state=active]:text-foreground"
>
<Check class="hidden size-3.5 group-data-[state=done]:block motion-safe:group-data-[state=done]:animate-pop" />
<LoaderCircle class="hidden size-3.5 group-data-[state=active]:block motion-safe:group-data-[state=active]:animate-spin" />
<span class="size-1.5 rounded-full bg-border-strong group-data-[state=done]:hidden group-data-[state=active]:hidden"></span>
</span>
<div class="grid min-w-0 gap-0.5 pt-0.5">
<p class="text-[0.8125rem]/4 font-medium text-muted-foreground transition-colors duration-200 ease-snappy group-data-[state=done]:text-foreground group-data-[state=active]:text-foreground">
{step.title}
</p>
<p class="text-xs/4 text-muted-foreground tabular-nums wrap-anywhere">{step.detail}</p>
</div>
</li>
);
})}
</ol>
</div>
<footer class="mt-5 flex flex-wrap items-center justify-between gap-2 border-t border-border pt-3.5 text-[0.75rem]/4 text-muted-foreground">
<button
type="button"
data-transfer-copy
data-copy-value={transactionId}
aria-label={`Copy transaction ID ${transactionId}`}
class="inline-flex min-w-0 cursor-pointer items-center gap-1.5 rounded-md font-mono text-[0.75rem]/4 text-muted-foreground tabular-nums transition-[color,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-100 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"
>
<span class="truncate">{transactionId}</span>
<Copy data-copy-idle aria-hidden="true" class="size-3.5 shrink-0" />
<Check data-copy-done aria-hidden="true" class="hidden size-3.5 shrink-0 text-success motion-safe:animate-pop" />
</button>
<span class="shrink-0 tabular-nums">{rateLockedAt}</span>
</footer>
<p data-transfer-live aria-live="polite" aria-atomic="true" class="sr-only"></p>
</section>
<script>
function enhance(root: HTMLElement) {
if (root.hasAttribute("data-enhanced")) return;
const badge = root.querySelector<HTMLElement>("[data-transfer-badge]");
const stepBtn = root.querySelector<HTMLButtonElement>("[data-transfer-step-btn]");
const btnLabel = root.querySelector<HTMLElement>("[data-transfer-btn-label]");
const iconAdvance = root.querySelector<SVGElement>("[data-transfer-icon-advance]");
const iconReplay = root.querySelector<SVGElement>("[data-transfer-icon-replay]");
const copyBtn = root.querySelector<HTMLButtonElement>("[data-transfer-copy]");
const copyIdle = root.querySelector<SVGElement>("[data-copy-idle]");
const copyDone = root.querySelector<SVGElement>("[data-copy-done]");
const live = root.querySelector<HTMLElement>("[data-transfer-live]");
const stepItems = Array.from(root.querySelectorAll<HTMLLIElement>("[data-transfer-step]"));
if (!badge || !stepBtn || !btnLabel || !stepItems.length) return;
const totalSteps = stepItems.length;
const activeLabel = root.dataset.statusActive || "In progress";
const doneLabel = root.dataset.statusDone || "Completed";
let currentStep = Number(root.dataset.step || "1");
let copyTimer = 0;
const render = (announce = false) => {
const completed = currentStep >= totalSteps;
root.dataset.step = String(currentStep);
stepItems.forEach((item, index) => {
const state = index < currentStep ? "done" : index === currentStep ? "active" : "pending";
item.dataset.state = state;
});
badge.toggleAttribute("data-complete", completed);
badge.textContent = completed ? doneLabel : activeLabel;
btnLabel.textContent = completed ? "Replay" : "Advance";
iconAdvance?.classList.toggle("hidden", completed);
iconReplay?.classList.toggle("hidden", !completed);
if (announce && live) {
if (completed) {
live.textContent = `Transfer ${doneLabel.toLowerCase()}.`;
} else {
const activeTitle = stepItems[currentStep]?.dataset.stepTitle ?? "Next step";
live.textContent = `${activeLabel}: ${activeTitle}.`;
}
}
};
stepBtn.addEventListener("click", () => {
currentStep = currentStep >= totalSteps ? 1 : currentStep + 1;
render(true);
});
copyBtn?.addEventListener("click", async () => {
const value = copyBtn.dataset.copyValue ?? "";
try {
await navigator.clipboard?.writeText(value);
} catch {
// Clipboard permission unavailable; still confirm the click visually.
}
window.clearTimeout(copyTimer);
copyIdle?.classList.add("hidden");
copyDone?.classList.remove("hidden");
if (live) live.textContent = `Copied transaction ID ${value}.`;
copyTimer = window.setTimeout(() => {
copyDone?.classList.add("hidden");
copyIdle?.classList.remove("hidden");
}, 1800);
});
render(false);
root.setAttribute("data-enhanced", "");
}
const init = () => document.querySelectorAll<HTMLElement>("[data-haze-currency-transfer]").forEach(enhance);
init();
if (!document.documentElement.hasAttribute("data-haze-currency-transfer-listener")) {
document.documentElement.setAttribute("data-haze-currency-transfer-listener", "");
document.addEventListener("astro:page-load", init);
}
</script>When to use
- Users track an active cross-border payout through payment, conversion, dispatch, and arrival milestones.
- Locked exchange rate, recipient bank details, and transaction reference need to stay visible on a compact vertical card.
When not to use
- Users need to enter an arbitrary amount and choose currencies from scratch. Use price-input or a form block instead.
- Multiple historical payouts should be compared in rows. Use table.
Installation
Add the Haze registry to components.json once, then install Currency Transfer with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/currency-transfernpx shadcn@latest add @haze/currency-transferyarn dlx shadcn@latest add @haze/currency-transferbunx --bun shadcn@latest add @haze/currency-transferFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| recipientName | string | "Lena Fischer" | Full name of the payout recipient. |
| recipientBank | string | "Deutsche Bank ··7823" | Destination bank name and masked account suffix. |
| recipientInitials | string | – | Optional avatar initials; derived from recipientName when omitted. |
| sentAmount | number | 500 | Amount sent in the source currency. |
| sourceCurrency | string | "USD" | ISO 4217 currency code for the sent amount. |
| receivedAmount | number | 460 | Converted amount delivered to the recipient. |
| targetCurrency | string | "EUR" | ISO 4217 currency code for the received amount. |
| transactionId | string | "TXN-DAB3UL494" | Copyable transaction reference code shown in the card footer. |
| rateLockedAt | string | "Rate locked 10:45 AM" | Timestamp note showing when the conversion rate was locked. |
| statusLabel | string | "In progress" | Badge label shown while transfer milestones are pending. |
| completedLabel | string | "Completed" | Badge label shown once every step completes. |
| initialStep | number | 1 | Zero-based active step index on initial render. |
| steps | TransferStep[] | – | Ordered transfer milestones with title and supporting detail. |
| headingLevel | 2 | 3 | 4 | 3 | Heading level for the recipient name. |
| class | string | – | Additional classes on the outer card. |
Keyboard interactions
- Tab then Enter or Space
- Step through the transfer milestones, replay progress, or copy the transaction ID.
Accessibility
- Step transitions and transaction ID copy feedback are announced via an aria-live polite status region.
- The spinning progress indicator respects prefers-reduced-motion via motion-safe:animate-spin.
- Without JavaScript, all four transfer steps, conversion totals, and the transaction reference render legibly.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Currency Transfer" with `npx shadcn@latest add @haze/currency-transfer`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import CurrencyTransfer from "@/components/haze/ui/currency-transfer.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/currency-transfer.md
Customize with real content
Adapt the Haze currency-transfer ui for our product. Replace the demo values of these props with our real content: recipientName, recipientBank, recipientInitials, sentAmount, sourceCurrency, receivedAmount, targetCurrency, transactionId, rateLockedAt, statusLabel, completedLabel, initialStep, steps, headingLevel, class. Keep the layout, the heading level rules and these accessibility details: Step transitions and transaction ID copy feedback are announced via an aria-live polite status region. The spinning progress indicator respects prefers-reduced-motion via motion-safe:animate-spin. Without JavaScript, all four transfer steps, conversion totals, and the transaction reference render legibly. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using currency-transfer, check it fits: use it when users track an active cross-border payout through payment, conversion, dispatch, and arrival milestones.; locked exchange rate, recipient bank details, and transaction reference need to stay visible on a compact vertical card.. Avoid it when users need to enter an arbitrary amount and choose currencies from scratch. use price-input or a form block instead.; multiple historical payouts should be compared in rows. use table.. Alternatives: @haze/price-input, @haze/card, @haze/timeline.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.