AsOf
- Status
- Implemented
- Family
- 1 of 13
- Registry
- @lopifi/as-of
npx shadcn@latest add @lopifi/theme @lopifi/as-ofThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
<AsOf date={lastSync} /> // "2m ago" · title="6 Sep 2026, 09:12 UTC"
Relative under an hour, absolute beyond. Timezone always stated in the absolute form. Updates from a single shared interval — never one setInterval per instance — and pauses on tab hide and off-screen.
Every figure in this system is accompanied by one of these. A balance without an "as of" is a rumor.
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/as-of.tsx
- Lopifi dependencies · 4
- cnfiscal-periodtooltipuse-shared-now
- npm packages
- @base-ui-components/reactclsxtailwind-merge
- Registry entry
- /r/as-of.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 { useSharedNow } from "@/hooks/ledger/use-shared-now";
import { cn } from "@/lib/ledger/cn";
import { formatDate, formatRelative, formatTimestamp } from "@/lib/ledger/fiscal-period";
import { Tooltip } from "@/components/ledger/tooltip";
export interface AsOfProps extends React.ComponentPropsWithoutRef<"time"> {
/**
* Beyond an hour, render the date alone and leave the clock time and zone to
* the tooltip. For dense meta rows, where the full stamp is the single
* longest run of text on a card and the least often read.
*
* Off by default: the unabridged form states its timezone inline, and that
* is the correct default for a figure whose basis is being asserted.
*/
compact?: boolean;
date: Date;
/** Suppress the absolute-timestamp tooltip — e.g. inside a cell that has its own. */
noTooltip?: boolean;
prefix?: string;
timeZone?: string;
}
/**
* A balance without an "as of" is a rumour.
*
* Relative under an hour, absolute beyond, timezone always stated. Driven by
* one shared interval that pauses on tab hide — never one per instance.
*/
export const AsOf = React.forwardRef<HTMLTimeElement, AsOfProps>(
({ className, date, timeZone = "UTC", prefix, noTooltip, compact, ...props }, ref) => {
const now = useSharedNow();
const absolute = formatTimestamp(date, timeZone);
const initial = compact ? formatDate(date) : absolute;
const [text, setText] = React.useState(initial);
// Render the absolute form on the server and on first paint so hydration
// matches; swap to relative once the client clock is available.
React.useEffect(() => {
const relative = formatRelative(date, now);
// `formatRelative` falls back to the full stamp beyond an hour; in
// compact mode that fallback is the date alone.
setText(compact && relative === formatTimestamp(date) ? formatDate(date) : relative);
}, [compact, date, now]);
// Supplementary by definition — the relative form is already readable, and
// the absolute one is a restatement. Exactly what a hover tooltip is for.
return (
<Tooltip content={absolute} disabled={noTooltip}>
<time
// A stamp never breaks: "30 Sep / 2026" across two lines reads as two
// facts. A tight row moves the whole stamp, not half of it.
className={cn("numeric whitespace-nowrap text-caption text-text-tertiary", className)}
dateTime={date.toISOString()}
ref={ref}
{...props}
>
{/* Words in the text face, the stamp in the figure face. */}
{prefix ? <span className="font-sans">{`${prefix} `}</span> : null}
{text}
</time>
</Tooltip>
);
},
);
AsOf.displayName = "AsOf";
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.
- 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
- As atThe point-in-time label for a balance sheetTerm
Elsewhere in the system
Where AsOf 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.
- AsOf, runningThe primitives showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Reading, paging and delta syncHow do you get everything out, and then keep it fresh?API
- Webhooks and freshnessHow do you find out something changed?API
- PrimitivesBuild these first. Everything above them inherits their mistakes. Specs for 15 React components: Money, Delta, Figure, Percent and 11 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 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.