Skip to content

StatementToolbar

Basis, period, comparison, currency, consolidation.
Implemented
Status
Implemented
Family
6 of 13
Registry
@lopifi/statement-toolbar
npx shadcn@latest add @lopifi/theme @lopifi/statement-toolbar

The component, rendering

Real data, the shipped component. Switch the theme to check the claims the spec makes below.

Preview

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.

components/ledger/statement-toolbar.tsx
"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.

Also in Statements

See also

A component is specified in one place, defined in another, and running in a third. All three, from here.

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.

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.

One address, no list rental, unsubscribe in one click.

Works in your QuickBooks Online or Xero file

Get your books closed every month

Lopifi is building AI bookkeeping that keeps your books closed on US GAAP as transactions happen, with a CPA review every quarter, for $200 a month. We’re not open yet.

$200/month when we open. No card now.