Rule
- Status
- Implemented
- Family
- 1 of 13
- Registry
- @lopifi/rule
npx shadcn@latest add @lopifi/theme @lopifi/ruleThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
The accounting rule lines. Two CSS declarations, four centuries of grammar.
<Rule variant="subtotal" /> // border-top: 1px solid --border
<Rule variant="total" /> // border-bottom: 3px double --border-strong
<Rule variant="section" /> // full-bleed 1px --border-subtle
Spans the numeric column only, not the label column. That's what makes it read as accounting rather than as a divider. In a multi-period statement it spans each period column independently, with the gutters unruled.
Never combined with a background fill on the same row.
Zero motion. Zero interactivity. Ten lines of code, and the single highest credibility-per-byte component in the library.
Lifted verbatim from Primitives. 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/rule.tsx
- Lopifi dependencies · 1
- cn
- npm packages
- clsxtailwind-merge
- Registry entry
- /r/rule.json
The whole component
No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
export interface RuleProps extends React.ComponentPropsWithoutRef<"div"> {
variant?: "subtotal" | "total" | "section";
}
/**
* Four centuries of accounting typography, two CSS declarations.
*
* A rule spans the numeric column only, never the label column — that is the
* actual convention, and it is what makes a statement read as accounting
* rather than as a styled table. Never combined with a background fill on
* the same row.
*/
export const Rule = React.forwardRef<HTMLDivElement, RuleProps>(
({ className, variant = "subtotal", ...props }, ref) => (
<div
aria-hidden="true"
className={cn(
variant === "subtotal" && "border-t border-border",
variant === "total" && "border-b-[3px] border-double border-border-strong",
variant === "section" && "border-t border-border-subtle",
className,
)}
data-rule={variant}
ref={ref}
{...props}
/>
),
);
Rule.displayName = "Rule";
/** The in-table form: a rule laid inside a cell, spanning the figures only. */
export function RuleCell({
variant = "subtotal",
className,
}: {
variant?: RuleProps["variant"];
className?: string;
}) {
return (
<td className={cn("px-3 py-0", className)}>
<Rule className="h-0 w-full" variant={variant} />
</td>
);
}
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 Primitives
- MoneyThe core primitive. A monetary value, formatted correctly.
- DeltaA signed change, with polarity and a redundant non-color cue.
- FigureA large display numeral with automatic size step-down.
- PercentPercent vs. percentage points, explicitly discriminated.
- StatusPillPayment and reconciliation states.
- SparklineInline trend, one-shot draw.
- TrendArrow + delta + optional sparkline, composed.
- AsOfTimestamp with live relative formatting and a stated timezone.
- RedactedMasked value with reveal.
- ReferenceCopyable transaction/account ID with disambiguated glyphs.
- CurrencyBadgeISO code + optional flag.
- EntityMarkBank/merchant logo with the full fallback ladder.
- TooltipHover/focus restatement. Never the only home of a fact.
- InfoTipThe ⓘ. Extra context that survives touch, because it opens on press.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Primitives — the family specThe four-layer specification this component was built against, before it was written.Doc
- Money and figure primitivesThe 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 Rule 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 Primitives 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.