StatementToolbar
- Status
- Implemented
- Family
- 6 of 13
- Registry
- @lopifi/statement-toolbar
npx shadcn@latest add @lopifi/theme @lopifi/statement-toolbarThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Basis (cash / accrual) · period · comparison · presentation currency · consolidation scope · expand-all/collapse-all · export.
The basis toggle is prominent and always visible. A P&L on cash basis versus accrual basis are different statements, and a user who doesn't know which they're looking at is being misled. This is not a settings-menu item.
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/statement-toolbar.tsx
- Lopifi dependencies · 9
- buttoncncurrency-badgecurrency-selectexport-menufiscal-periodiconsmoney.typesperiod-picker
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/statement-toolbar.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 { AccountingBasis } from "@/lib/ledger/money.types";
import { Button } from "@/components/ledger/button";
import { CurrencySelect } from "@/components/ledger/currency-select";
import { ExportMenu } from "@/components/ledger/export-menu";
import { ArrowsPointingInIcon, ChevronUpDownIcon } from "@/components/ledger/icons";
import { PeriodPicker, type PeriodSelection } from "@/components/ledger/period-picker";
export interface StatementToolbarProps {
basis: AccountingBasis;
className?: string;
comparison: string;
consolidation: string;
currency: string;
fiscalYearStartMonth?: number;
onBasisChange: (b: AccountingBasis) => void;
onCollapseAll?: () => void;
onComparisonChange: (c: string) => void;
onConsolidationChange: (c: string) => void;
onCurrencyChange: (c: string) => void;
onExpandAll?: () => void;
onExport?: (format: "csv" | "xlsx" | "pdf") => void;
onPeriodChange: (p: PeriodSelection) => void;
period: PeriodSelection;
}
const COMPARISONS = ["Prior period", "Prior year", "Budget", "Forecast", "None"];
/**
* The basis toggle is prominent and always visible. A P&L on cash basis and
* the same P&L on accrual basis are different statements, and a user who
* doesn't know which they're looking at is being misled. This is not a
* settings-menu item.
*/
export function StatementToolbar({
basis,
onBasisChange,
period,
onPeriodChange,
fiscalYearStartMonth = 1,
comparison,
onComparisonChange,
currency,
onCurrencyChange,
consolidation,
onConsolidationChange,
onExpandAll,
onCollapseAll,
onExport,
className,
}: StatementToolbarProps) {
return (
<div
className={cn(
"no-print flex flex-wrap items-center gap-2 rounded-md border border-border bg-surface p-3",
className,
)}
>
<div
aria-label="Accounting basis"
className="flex rounded-sm border border-border-strong p-0.5"
role="radiogroup"
>
{(["accrual", "cash"] as const).map((b) => (
<button
aria-checked={basis === b}
className={cn(
"press h-7 rounded-xs px-3 text-label font-medium capitalize",
basis === b
? "bg-surface-selected text-text-primary"
: "text-text-secondary hover:bg-surface-hover",
)}
key={b}
onClick={() => onBasisChange(b)}
role="radio"
type="button"
>
{b}
</button>
))}
</div>
<PeriodPicker
fiscalYearStartMonth={fiscalYearStartMonth}
onValueChange={onPeriodChange}
value={period}
/>
<label className="flex items-center gap-2">
<span className="sr-only">Comparison</span>
<select
className="h-8 rounded-sm border border-border bg-surface px-2 text-label outline-none focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent-subtle"
onChange={(e) => onComparisonChange(e.target.value)}
value={comparison}
>
{COMPARISONS.map((c) => (
<option key={c}>{c}</option>
))}
</select>
</label>
<CurrencySelect
className="h-8"
label="Presentation currency"
onValueChange={onCurrencyChange}
value={currency}
/>
<label className="flex items-center gap-2">
<span className="sr-only">Consolidation scope</span>
<select
className="h-8 rounded-sm border border-border bg-surface px-2 text-label outline-none focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent-subtle"
onChange={(e) => onConsolidationChange(e.target.value)}
value={consolidation}
>
<option>Consolidated</option>
<option>Parent standalone</option>
<option>Northwind Ltd</option>
<option>Northwind GmbH</option>
</select>
</label>
<div className="ml-auto flex flex-wrap items-center gap-2">
<Button aria-label="Expand all rows" onClick={onExpandAll} size="sm" variant="ghost">
<ChevronUpDownIcon aria-hidden="true" className="size-3.5" />
Expand all
</Button>
<Button aria-label="Collapse all rows" onClick={onCollapseAll} size="sm" variant="ghost">
<ArrowsPointingInIcon aria-hidden="true" className="size-3.5" />
Collapse all
</Button>
{onExport ? (
<ExportMenu
onExport={onExport}
scopeCount={1}
scopeDescription="statement with the resolved period and basis"
/>
) : null}
</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.
- Accrual basisRecognizing revenue when earned and expense when incurred, regardless of when cash moves
- BasisCash or accrual
- Cash basisRecognizing revenue and expense only when cash moves. Not GAAP for any entity — it is a special purpose framework (AICPA AU-C 800), and for tax a method IRS Pub. 538 and IRC §448 limit by entity type and gross receipts
- P&LPerformance over a period
- PeriodA fiscal reporting window
- Presentation currencyThe currency the statements are shown in. ASC 830 calls it the reporting currency; IAS 21 the presentation currency — we use the latter
- 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.
- BalanceSheetAssets / liabilities / equity, with the balance check.
- CashFlowStatementOperating / investing / financing.
- 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
- Accrual basisRecognizing revenue when earned and expense when incurred, regardless of when cash movesTerm
Elsewhere in the system
Where StatementToolbar 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.
- StatementToolbar, runningThe statements showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- 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.