TableColumns
Sort and resize for a table that renders on the server.
npx shadcn add @lopifi/table-columnsHow it behaves
What it renders, what it refuses to render, and why. The same paragraphs as the family spec, so the two can’t disagree.
Sortable, resizable columns for a table that renders on the server.
The sibling of GridKeyboard, for the same reason. Most ledger tables here are server
components, because a 400-row statement shouldn't ship 400 rows of JavaScript to be rendered
twice. But bookkeepers come from Excel, where every column sorts and drags, and rewriting
nineteen tables as client components is the worse trade.
So it wraps the table the server produced instead of replacing it. Header cells become sort
controls with a resize handle, an injected (or adopted) <colgroup> carries the widths, and
rows are reordered in place. Any table in the catalog gets both behaviors without knowing this
component exists.
<TableColumns storageKey="gl-detail" onOpenRow={(i) => setDrilldown(i)}>
<GridKeyboard>
<LedgerTable … />
</GridKeyboard>
</TableColumns>
Sorting#
- Three states, not two: ascending, descending, and back to the ledger's own order. A journal's source order is information, and a table you can't un-sort loses it.
- Numbers and dates open at the big end, text opens at A. The question behind clicking an amount column is "what's the largest", never "what's the smallest", and a first click that shows the oldest row looks like a bug.
- Sorts the value, not the presentation:
data-sort, then thedata-rawthatMoneyalready stamps, then the text. Sorted as text,($1,240.56)sorts by its opening parenthesis. nullis not0. Blanks sort last in both directions. Flip them to the top on a descending sort and a reviewer concludes twelve accounts have no balance, when the balances just aren't known yet.- Stable. Rows that tie keep the order the ledger gave them — date, then entry number.
- Status columns sort by workflow, not alphabet. A–Z puts
cancelledaboveoverdue.
What it refuses to sort#
- A hierarchy.
data-levelrows (a chart of accounts) ordata-row-variantrows (subtotals, section heads) carry meaning in their order. A subtotal floating away from the rows it totals is worse than an unsorted table. Those tables still resize. - A table that opted out.
data-sortable="false"on the<table>, set by the component, not the caller. A register's running balance only means something in date order, and the register knows that. tfoot. Totals are not rows of the population.- A page of a larger set. Sorting the page answers "largest amount" with the largest
of ninety-four rows out of twelve thousand, and it looks exactly right. Pass
sortable={false}and sort at the source.
Resizing#
Account names, memos and vendor names have no natural length. The width that fits one client's chart of accounts truncates another's on every row, and two truncated account names look identical. That's a correctness problem, not just a layout one.
- A 9px hit area centered on the seam, with a 1px line that paints only on hover, focus or drag. A visible grabber on every boundary turns a ledger into a grid of handles.
- The handle is a real
separatorwitharia-valuenow. Arrows move it 16px,Alt+arrows 1px, andHomeor a double-click restores the shipped width. - Measured from the start of the drag, never accumulated per move, which drifts away from the cursor.
- Persisted per user per table on pointer-up, never per move. Stored widths are clamped to today's bounds and dropped for columns that no longer exist, because the table's shape outlives the preference.
- The slack goes to one column, the widest at first paint, which is reliably the label column. A fixed-layout table narrower than its card leaves a gap, and a ruled card with a gap looks like a rendering bug.
- A body cell clips; a figure cell does not. A truncated label is an inconvenience the reader can undo. A figure missing its leading digit is wrong.
Row detail#
onOpenRow fires on double-click and on Enter. People bring double-click from every
ledger they've used, and Enter works without a mouse. Pair it with DrilldownSheet or TransactionDetail.
The accounting it encodes
The concepts this component renders, each defined once in the lexicon.
More in Ledger & tables
See also
Where this component is specified, defined and running.
Elsewhere in the system
The live section TableColumns renders in, the calculators behind its figures, and the ledger payloads that feed it.
- TableColumns, runningThe tables showcase — live, with theme, density, grayscale and reduced-motion switches.
- Ledger & tablesThe table is the product. It gets the same design attention as the hero card. Specs for 17 React components: TransactionTable, TransactionRow, TransactionCard, TransactionDetail and 13 more.
Components are copied into your repository and meant to be edited. Rounding policy, fiscal calendar and compliance copy differ per company.
Release notes
Get an email when Ledger & tables changes
Your copy doesn’t update itself when we fix something here.
- One email when a Ledger & tables component needs a migration
- Nothing when nothing changes
Or install it now