AccountCard
- Status
- Implemented
- Family
- 2 of 13
- Registry
- @lopifi/account-card
npx shadcn@latest add @lopifi/theme @lopifi/account-cardThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Bank account: institution mark, masked number, type, available and current balances, sync status. Tapping opens the transaction list filtered to it.
Handles disconnected and reauth-required states prominently — a stale bank connection silently showing an old balance is a real financial hazard. Stale accounts dim and surface a "Reconnect" action.
Lifted verbatim from Cards. 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/account-card.tsx
- Lopifi dependencies · 14
- as-ofbuttoncardcnentity-markfiscal-periodformat-moneyiconsinfo-tipmoneymoney.typesreferencetooltipuse-shared-now
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/account-card.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 * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { formatTimestamp } from "@/lib/ledger/fiscal-period";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { AsOf } from "@/components/ledger/as-of";
import { Button } from "@/components/ledger/button";
import { Card } from "@/components/ledger/card";
import { EntityMark } from "@/components/ledger/entity-mark";
import { ChevronRightIcon, ExclamationTriangleIcon } from "@/components/ledger/icons";
import { InfoTip } from "@/components/ledger/info-tip";
import { Money } from "@/components/ledger/money";
import { MaskedAccount } from "@/components/ledger/reference";
export interface AccountCardProps extends React.ComponentPropsWithoutRef<"div"> {
accountType: string;
available: MoneyValue | null;
connection?: "connected" | "disconnected" | "reauth-required";
current: MoneyValue | null;
institution: string;
institutionSrc?: string;
last4: string;
lastSynced: Date;
onOpen?: () => void;
onReconnect?: () => void;
}
/**
* A stale bank connection silently showing an old balance is a real
* financial hazard, so disconnected and reauth-required are prominent
* states, not a subtle badge.
*/
export const AccountCard = React.forwardRef<HTMLDivElement, AccountCardProps>(
(
{
className,
institution,
institutionSrc,
accountType,
last4,
available,
current,
lastSynced,
connection = "connected",
onOpen,
onReconnect,
...props
},
ref,
) => {
const broken = connection !== "connected";
const syncedAt = formatTimestamp(lastSynced);
return (
<Card className={cn("flex flex-col gap-4", className)} ref={ref} stale={broken} {...props}>
<div className="flex items-start gap-3">
<EntityMark category="bank" name={institution} size={40} src={institutionSrc} />
<div className="min-w-0 flex-1">
<p className="truncate text-body font-medium">{institution}</p>
<p className="flex items-center gap-2 text-caption text-text-secondary">
{accountType}
<span aria-hidden="true">·</span>
<MaskedAccount last4={last4} />
</p>
</div>
{onOpen ? (
<Button
aria-label={`Open ${institution} transactions`}
onClick={onOpen}
size="icon"
variant="ghost"
>
<ChevronRightIcon aria-hidden="true" className="size-4" />
</Button>
) : null}
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<span className="block text-caption text-text-secondary">Available</span>
<Money className="mt-0.5" size="md" value={available} />
</div>
<div>
<span className="block text-caption text-text-secondary">Current</span>
<Money className="mt-0.5" size="md" tone="secondary" value={current} />
</div>
</div>
{broken ? (
<div className="flex items-center gap-2 rounded-sm bg-negative-subtle px-3 py-2">
<ExclamationTriangleIcon aria-hidden="true" className="size-3.5 shrink-0 text-negative" />
<span className="flex min-w-0 flex-1 items-center gap-1.5">
<span className="truncate text-caption font-medium text-negative">
{connection === "reauth-required" ? "Reauthorization required" : "Disconnected"}
</span>
<InfoTip
about={`Why ${institution} needs reconnecting`}
align="start"
label="This balance may be out of date"
side="top"
triggerClassName="text-negative"
>
{connection === "reauth-required"
? `${institution} revoked this connection's authorization — usually a password change or an expired consent.`
: `The connection to ${institution} is down.`}{" "}
Last synced {syncedAt}.
</InfoTip>
</span>
<Button onClick={onReconnect} size="sm" variant="secondary">
Reconnect
</Button>
</div>
) : (
<AsOf date={lastSynced} prefix="Synced" />
)}
</Card>
);
},
);
AccountCard.displayName = "AccountCard";
The accounting it encodes
Concepts this component renders. Each one is defined once, in the lexicon, and used identically in the code and the copy.
Also in Cards
- BalanceCardThe hero: one trusted number.
- KpiCardMetric + delta + optional sparkline.
- PaymentMethodCardThe physical card object. 3D flip, pointer tilt.
- RunwayCardMonths of runway with a burn line.
- InvoiceCardInvoice summary with aging state.
- SubscriptionCardRecurring charge with next-billing.
- AnomalyCardA flagged deviation with its explanation.
- GoalCardTarget vs. actual with a progress rule.
- StatCardThe minimal label+value card.Spec
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Cards — the family specThe four-layer specification this component was built against, before it was written.Doc
- Balance, KPI and account cardsThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- AccountA GL account in the chart of accounts. Always qualify when a bank account is meant.Term
Elsewhere in the system
Where AccountCard 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.
- AccountCard, runningThe cards showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Chart of accountsHow does each ledger model an account?API
- CardsAll cards: 24px radius, 24px inset, --surface on --canvas, 1px --border, no resting shadow. Specs for 10 React components: BalanceCard, KpiCard, AccountCard, PaymentMethodCard and 6 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 Cards 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.