BalanceSheet
- Status
- Implemented
- Family
- 6 of 13
- Registry
- @lopifi/balance-sheet
npx shadcn@latest add @lopifi/theme @lopifi/balance-sheetThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Assets → Liabilities → Equity, with the accounting identity checked and displayed.
- The balance check is a first-class UI element, not a footnote.
Assets 4,281,900 = Liabilities 1,840,200 + Equity 2,441,700 ✓— and when it doesn't balance, that's a prominent error state with the difference stated, not a silently wrong statement. - Current vs. non-current sub-grouping.
- As-of date, not a period — a balance sheet is a point in time and labeling it with a range is a category error the component prevents by taking a
Date, not a range. - Comparative columns: this date vs. prior period end vs. prior year end.
Lifted verbatim from Statements. 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/balance-sheet.tsx
- Lopifi dependencies · 14
- cncolumn-managerfiscal-periodformat-moneyiconsmoneymoney.typespercentperiod-changerulestatement-tabletooltipuse-scroll-edgesvariance-cell
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/balance-sheet.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 { formatDate } from "@/lib/ledger/fiscal-period";
import { CheckIcon, ExclamationTriangleIcon } from "@/components/ledger/icons";
import { Money } from "@/components/ledger/money";
import {
type DrilldownTarget,
type StatementHeader,
type StatementLine,
StatementTable,
} from "@/components/ledger/statement-table";
export interface BalanceSheetProps {
/** A balance sheet is a point in time. Taking a Date, not a range, makes
"September 2026" a category error the type system prevents. */
asOf: Date;
className?: string;
/** Offer the period columns to hide. See `StatementTable`. */
columnManager?: boolean;
comparativeDates?: Date[];
header: Omit<StatementHeader, "statement" | "periodLabel">;
lines: StatementLine[];
/** Caps the scroller so the column headers freeze. See `StatementTable`. */
maxHeight?: number;
onDrilldown?: (line: StatementLine, target: DrilldownTarget) => void;
/** Passed in, already computed, per column. */
totals: { assets: number[]; liabilities: number[]; equity: number[] };
}
/**
* The accounting identity is a first-class UI element, not a footnote.
* When it doesn't balance, that is a prominent error state with the
* difference stated — never a silently wrong statement.
*/
export function BalanceSheet({
asOf,
comparativeDates = [],
header,
lines,
totals,
onDrilldown,
maxHeight,
columnManager,
className,
}: BalanceSheetProps) {
const dates = [asOf, ...comparativeDates];
const periods = dates.map((d) => `As of ${formatDate(d)}`);
return (
<div className={cn("w-full", className)}>
<StatementTable
columnManager={columnManager}
header={{
...header,
periodLabel: `As of ${formatDate(asOf)}`,
statement: "Balance sheet",
}}
lines={lines}
maxHeight={maxHeight}
onDrilldown={onDrilldown}
periods={periods}
/>
<div className="mt-4 space-y-2">
{dates.map((d, i) => {
const assets = totals.assets[i];
const liabilities = totals.liabilities[i];
const equity = totals.equity[i];
const difference = assets - (liabilities + equity);
const balanced = difference === 0;
return (
<div
className={cn(
"flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border px-4 py-3",
balanced ? "border-positive bg-positive-subtle" : "border-negative bg-negative-subtle",
)}
key={d.toISOString()}
role={balanced ? undefined : "alert"}
>
{balanced ? (
<CheckIcon aria-hidden="true" className="size-4 shrink-0 text-positive" />
) : (
<ExclamationTriangleIcon aria-hidden="true" className="size-4 shrink-0 text-negative" />
)}
<span className="text-caption text-text-secondary">{formatDate(d)}:</span>
<span className="flex flex-wrap items-baseline gap-1 text-body">
Assets <Money accounting value={{ amount: assets, currency: header.currency }} />
<span aria-hidden="true">=</span>
Liabilities <Money accounting value={{ amount: liabilities, currency: header.currency }} />
<span aria-hidden="true">+</span>
Equity <Money accounting value={{ amount: equity, currency: header.currency }} />
</span>
{balanced ? (
<span className="text-body font-medium text-positive">Balanced</span>
) : (
<span className="flex items-baseline gap-1 text-body font-medium text-negative">
Out by{" "}
<Money
accounting
tone="inherit"
value={{ amount: difference, currency: header.currency }}
/>
</span>
)}
</div>
);
})}
</div>
</div>
);
}
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.
- As atThe point-in-time label for a balance sheet
- AssetA present right of the entity to an economic benefit (FASB CON 8 ¶E16)
- Balance sheetAssets, liabilities and equity at a point in time, proving the accounting equation
- ComparativeA prior period column
- EquityThe residual interest in the assets that remains after deducting liabilities (FASB CON 8 ¶E61)
- StatementP&L, balance sheet, or cash flow
Also in Statements
- StatementTableThe shared shell: hierarchy, periods, rules.
- StatementRowIndent level, subtotal, total, expand.
- ProfitAndLossP&L with period comparison and variance.
- CashFlowStatementOperating / investing / financing.
- StatementToolbarBasis, period, comparison, currency, consolidation.
- PeriodPickerFiscal-aware. Never assumes January.
- VarianceCellAbsolute + percent + significance flag.
- FluxAnalysisPeriod-over-period explanations.
- DrilldownSheetStatement line → the GL entries behind it.
- TrialBalanceAll accounts with the debit=credit proof.
- CloseChecklistTasks, owners, blockers, sign-off.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Statements — the family specThe four-layer specification this component was built against, before it was written.Doc
- Financial statement componentsThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- As atThe point-in-time label for a balance sheetTerm
Elsewhere in the system
Where BalanceSheet 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.
- BalanceSheet, runningThe statements showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- ReportsShould you build statements on the reports endpoints?API
- StatementsThe largest gap in the market. No component library ships a <BalanceSheet />. This family is the reason Lopifi exists. Specs for 12 React components: StatementTable, StatementRow, ProfitAndLoss, BalanceSheet and 8 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 Statements 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.