RevenueWaterfall
- Status
- Implemented
- Family
- 9 of 13
- Registry
- @lopifi/revenue-waterfall
npx shadcn@latest add @lopifi/theme @lopifi/revenue-waterfallThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
The deferred revenue balance recognizing by future period, by performance obligation. The number every SaaS board asks for. Bars, not a table, with the table equivalent behind DataTableToggle.
Lifted verbatim from Accounting core (GL). 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/revenue-waterfall.tsx
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/revenue-waterfall.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 { axisLabel, niceTicks, vizColorFor } from "@/lib/ledger/chart-utils";
import { DataTableToggle } from "@/components/ledger/chart-primitives";
import { Money } from "@/components/ledger/money";
export type RecognitionBucket = {
period: string;
/** Minor units, by performance obligation. */
byObligation: Record<string, number>;
};
export interface RevenueWaterfallProps {
buckets: RecognitionBucket[];
className?: string;
currency: string;
obligations: string[];
}
/**
* The deferred revenue balance recognizing by future period, by performance
* obligation. The number every SaaS board asks for.
*/
export function RevenueWaterfall({ buckets, obligations, currency, className }: RevenueWaterfallProps) {
const width = 720;
const height = 280;
const PAD = { bottom: 40, left: 72, right: 16, top: 16 };
const totals = buckets.map((b) => obligations.reduce((s, o) => s + (b.byObligation[o] ?? 0), 0));
const ticks = niceTicks(0, Math.max(...totals, 1));
const max = ticks[ticks.length - 1];
const plotW = width - PAD.left - PAD.right;
const plotH = height - PAD.top - PAD.bottom;
const y = (v: number) => PAD.top + plotH - (v / (max || 1)) * plotH;
const slot = plotW / buckets.length;
const barW = slot * 0.66;
return (
<DataTableToggle
className={className}
table={
<table className="w-full text-body">
<caption className="sr-only">Deferred revenue recognition schedule</caption>
<thead>
<tr className="border-b border-border-subtle">
<th className="py-2 text-left text-label text-text-secondary" scope="col">
Period
</th>
{obligations.map((o) => (
<th className="py-2 text-right text-label text-text-secondary" key={o} scope="col">
{o}
</th>
))}
<th className="py-2 text-right text-label text-text-secondary" scope="col">
Total
</th>
</tr>
</thead>
<tbody>
{buckets.map((b, i) => (
<tr className="border-b border-border-subtle" key={b.period}>
<th className="py-2 text-left font-normal" scope="row">
{b.period}
</th>
{obligations.map((o) => (
<td className="py-2 text-right" key={o}>
<Money accounting value={{ amount: b.byObligation[o] ?? 0, currency }} />
</td>
))}
<td className="py-2 text-right">
<Money accounting value={{ amount: totals[i], currency }} />
</td>
</tr>
))}
</tbody>
</table>
}
>
<svg
aria-label="Deferred revenue recognizing by future period"
className="w-full"
role="img"
style={{ height }}
viewBox={`0 0 ${width} ${height}`}
>
{ticks.map((t) => (
<g key={t}>
<line stroke="var(--border-subtle)" x1={PAD.left} x2={width - PAD.right} y1={y(t)} y2={y(t)} />
<text
className="numeric"
fill="var(--text-tertiary)"
fontSize="12"
textAnchor="end"
x={PAD.left - 8}
y={y(t) + 4}
>
{axisLabel(t, currency)}
</text>
</g>
))}
<line stroke="var(--border-strong)" x1={PAD.left} x2={width - PAD.right} y1={y(0)} y2={y(0)} />
{buckets.map((b, i) => {
const x = PAD.left + i * slot + (slot - barW) / 2;
let cursor = 0;
return (
<g key={b.period}>
{obligations.map((o) => {
const v = b.byObligation[o] ?? 0;
const top = y(cursor + v);
const h = Math.max(0, y(cursor) - y(cursor + v));
cursor += v;
return <rect fill={vizColorFor(o)} height={h} key={o} width={barW} x={x} y={top} />;
})}
<text
className="numeric"
fill="var(--text-secondary)"
fontSize="11"
textAnchor="middle"
x={x + barW / 2}
y={y(totals[i]) - 6}
>
{axisLabel(totals[i], currency)}
</text>
<text
className="numeric"
fill="var(--text-tertiary)"
fontSize="12"
textAnchor="middle"
x={x + barW / 2}
y={height - 20}
>
{b.period}
</text>
</g>
);
})}
</svg>
<ul className="mt-3 flex flex-wrap gap-4">
{obligations.map((o) => (
<li className="flex items-center gap-2 text-caption" key={o}>
<span
aria-hidden="true"
className="size-2.5 rounded-[2px]"
style={{ background: vizColorFor(o) }}
/>
{o}
</li>
))}
</ul>
</DataTableToggle>
);
}
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.
- Deferred revenueConsideration received, or unconditionally due, before the goods or services are transferred — a liability until the performance obligation is satisfied. ASC 606 calls it a contract liability
- Performance obligationA promise in a contract to transfer a distinct good or service, or a series of substantially the same ones — the unit revenue is recognized by
- PeriodA fiscal reporting window
- RevenueInflows or enhancements of assets, or settlements of liabilities, from delivering goods or services — recognized when control transfers, not when cash arrives
Also in Accounting core (GL)
- JournalEntryDebit and credit as two columns. No signed-column variant.
- JournalEntryFormLine grid with live balance check and dimension capture.
- JournalEntryTableAll entries, with the gapless-numbering check.
- AccountPickerShows the normal balance. Blocks non-postable accounts.
- ChartOfAccountsHierarchy, statement mapping, unsupported-account flags.
- AccountRegisterGL detail with a running balance.
- DimensionPickerEntity always required; renders what the account demands.
- AdjustingEntryFormTemplated by type. Auto-reverse defaults on for accruals.
- RecurringEntryTemplateTemplate editable; instances read-only.
- EntryReversalDialogHold-to-confirm. Never a delete.
- ScheduleTableOne shell, seven presets. Prepaids through debt.
- RollForwardOpening → movements → closing → tie. The universal shape.
- AccountTieOutEvery BS account, proven against its evidence.
- SchedulePreviewWhat the schedules will post, before they post.
- DepreciationScheduleBook and tax in parallel. In-service date, not purchase date.
- LeaseScheduleROU asset and liability on diverging curves.
- AllowanceRollForwardWith the methodology shown, not just the number.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Accounting core (GL) — the family specThe four-layer specification this component was built against, before it was written.Doc
- General ledger and accounting coreThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- Deferred revenueConsideration received, or unconditionally due, before the goods or services are transferred — a liability until the performance obligation is satisfied. ASC 606 calls it a contract liabilityTerm
Elsewhere in the system
Where RevenueWaterfall 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.
- RevenueWaterfall, runningThe charts showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Prepaid & deferred releaseA premium paid on the 17th does not release in twelve equal slices. Day-weighted, or even — your call.Tool
- Accounting core (GL)The general ledger layer. Specs for 18 React components: JournalEntry, JournalEntryForm, JournalEntryTable, AccountPicker and 14 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 Accounting core (GL) 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.