Skip to content

StatementRow

Indent level, subtotal, total, expand.
Implemented
Status
Implemented
Family
6 of 13
Registry
@lopifi/statement-row
npx shadcn@latest add @lopifi/theme @lopifi/statement-row

The component, rendering

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

Preview

The four-layer spec

One line. Indent level, label, N period values, expand toggle, subtotal/total variant, drill-down affordance.

Server-safe (no "use client") — a 400-row statement renders on the server. This is why Money, Rule, and StatementRow are all RSC-compatible; it's a real performance decision, not a purity one.

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-row.tsx

Lopifi dependencies · 6
cnformat-moneymoneymoney.typesruletooltip
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/statement-row.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-row.tsx
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import type { MoneyValue, StatementRowVariant } from "@/lib/ledger/money.types";
import { Money } from "@/components/ledger/money";

export interface StatementRowProps extends React.ComponentPropsWithoutRef<"tr"> {
  expandable?: boolean;
  expanded?: boolean;
  label: string;
  level?: number;
  onToggle?: () => void;
  values: (MoneyValue | null)[];
  variant?: StatementRowVariant;
}

/**
 * One line. Server-safe (no `"use client"`) — a 400-row statement renders on
 * the server, which is why `Money`, `Rule` and this component all stay RSC-
 * compatible. That is a performance decision, not a purity one.
 */
export const StatementRow = React.forwardRef<HTMLTableRowElement, StatementRowProps>(
  (
    { className, label, level = 1, variant = "line", values, expandable, expanded, onToggle, ...props },
    ref,
  ) => {
    const emphasized = variant === "subtotal" || variant === "total";
    const accessibleLabel =
      variant === "total" ? `${label}, grand total` : variant === "subtotal" ? `${label}, subtotal` : label;

    return (
      <tr
        className={cn("border-b border-border-subtle", className)}
        data-row-variant={variant}
        ref={ref}
        {...props}
      >
        <th
          className={cn(
            "py-3 pr-4 text-left font-normal",
            emphasized && "font-medium",
            variant === "section" && "text-title-sm font-medium",
          )}
          data-level={level}
          scope="row"
          style={{ paddingLeft: 24 + 24 * (level - 1) }}
        >
          {expandable ? (
            <button
              aria-expanded={expanded}
              className="mr-1 text-text-tertiary"
              onClick={onToggle}
              type="button"
            >
              {expanded ? "−" : "+"}
            </button>
          ) : null}
          {accessibleLabel}
        </th>
        {values.map((v, i) => (
          <td className="px-3 py-3 text-right" key={i}>
            {variant === "section" ? null : (
              <Money accounting size={variant === "total" ? "md" : "sm"} statement value={v} />
            )}
          </td>
        ))}
      </tr>
    );
  },
);
StatementRow.displayName = "StatementRow";

export { Rule } from "@/components/ledger/rule";

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 StatementRow 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.