Reference
- Status
- Implemented
- Family
- 1 of 13
- Registry
- @lopifi/reference
npx shadcn@latest add @lopifi/theme @lopifi/referenceThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Transaction and account IDs. "zero" 1, "ss02" 1 so 0/O and 1/l/I are unambiguous — these get transcribed by humans into other systems. Click to copy; copies the raw value. Truncates in the middle (txn_8a2…f091), never at the end, because the tail is the discriminating part.
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/reference.tsx
- Lopifi dependencies · 3
- cniconstooltip
- npm packages
- @base-ui-components/reactclsxtailwind-merge
- Registry entry
- /r/reference.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 * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { CheckIcon, DocumentDuplicateIcon } from "@/components/ledger/icons";
import { Tooltip } from "@/components/ledger/tooltip";
export interface ReferenceProps extends React.ComponentPropsWithoutRef<"span"> {
copyable?: boolean;
label?: string;
/** Truncate in the middle; the tail is the discriminating part. */
truncate?: boolean;
value: string;
}
/**
* Transaction and account IDs — the strings humans transcribe into other
* systems. `zero` slashes the 0 and `ss02` separates 1 / l / I, so nobody
* mistypes an IBAN. Copy takes the raw value.
*/
export const Reference = React.forwardRef<HTMLSpanElement, ReferenceProps>(
({ className, value, truncate = true, copyable = true, label = "Reference", ...props }, ref) => {
const [copied, setCopied] = React.useState(false);
const shown = truncate && value.length > 18 ? `${value.slice(0, 8)}…${value.slice(-4)}` : value;
const copy = React.useCallback(() => {
navigator.clipboard?.writeText(value).then(
() => {
setCopied(true);
setTimeout(() => setCopied(false), 1600);
},
() => setCopied(false),
);
}, [value]);
return (
<span className={cn("inline-flex items-center gap-1", className)} ref={ref} {...props}>
<Tooltip content={shown === value ? null : value}>
<span className="reference-numeric text-caption text-text-secondary">{shown}</span>
</Tooltip>
{copyable ? (
<button
aria-label={copied ? `${label} copied` : `Copy ${label.toLowerCase()} ${value}`}
className={cn(
"press grid size-6 place-items-center rounded-xs text-text-tertiary",
"hover:bg-surface-hover",
)}
onClick={copy}
type="button"
>
{copied ? (
<CheckIcon aria-hidden="true" className="size-3 text-positive" />
) : (
<DocumentDuplicateIcon aria-hidden="true" className="size-3" />
)}
</button>
) : null}
</span>
);
},
);
Reference.displayName = "Reference";
/** Account numbers show last 4 only; the mask is aria-hidden. */
export function MaskedAccount({ last4, className }: { last4: string; className?: string }) {
return (
<span className={cn("reference-numeric relative text-caption text-text-secondary", className)}>
<span aria-hidden="true">•••• {last4}</span>
<span className="sr-only select-none">account ending {last4}</span>
</span>
);
}
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.
- RuleSingle / double / section accounting rule lines.
- 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.
- 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 Reference 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.