Search docs

Jump to any table example

Shadcn Table for Bank Transactions

A bank statement: transactions grouped by day, debit and credit columns, a running balance, and pending transactions that stay out of the balance until they clear.

$ npx shadcn add https://www.shad-table.dev/r/transactions-table.json
Opening balance
$12,842.50
Money in
+$5,877.64
Money out
$3,191.58
Current balance
$15,528.56
Pending
-$336.67
Available
$15,146.89
DescriptionStatusDebitCreditBalance
Today · Mon, Nov 30End of day balance $15,528.56
Hotel deposit · The Marlow
Travel
Pending$250.00—not in the balance until it clears
Shell Station 0442
Transport
Pending$61.05—not in the balance until it clears
Venmo · J. Weber
Transfer
Pending+$45.00—not in the balance until it clears
Yesterday · Sun, Nov 29$2.99End of day balance $15,528.56
Target
Shopping
Pending$64.72—not in the balance until it clears
Blue Bottle Coffee
Dining
Pending$5.90—not in the balance until it clears
Apple iCloud
Subscriptions
Cleared$2.99$15,528.56
Sat, Nov 28$50.57End of day balance $15,531.55
Uber
Transport
Cleared$23.12$15,531.55
Corner Market
Groceries
Cleared$27.45$15,554.67
Fri, Nov 27$386.40+$2.14End of day balance $15,582.12
Interest Paid
Income
Cleared+$2.14$15,582.12
Delta Air Lines
Travel
Cleared$386.40$15,579.98
Thu, Nov 26$127.55End of day balance $15,966.38
Netflix
Subscriptions
Cleared$15.49$15,966.38
Whole Foods
Groceries
Cleared$112.06$15,981.87
Wed, Nov 25$126.68End of day balance $16,093.93
ATM Fee
Fees
Cleared$3.50$16,093.93
ATM Withdrawal
Cash
Cleared$100.00$16,097.43
CVS Pharmacy
Health
Cleared$23.18$16,197.43
Tue, Nov 24$79.99+$1,200.00End of day balance $16,220.61
Freelance · Globex invoice #118
Income
Cleared+$1,200.00$16,220.61
Comcast Internet
Utilities
Cleared$79.99$15,020.61
Mon, Nov 23$73.40End of day balance $15,100.60
Lucia’s Trattoria
Dining
Cleared$73.40$15,100.60
Sun, Nov 22$89.14+$32.00End of day balance $15,174.00
Venmo · M. Chen
Transfer
Cleared+$32.00$15,174.00
Trader Joe’s
Groceries
Cleared$89.14$15,142.00
Sat, Nov 21$127.00End of day balance $15,231.14
Metro Transit Pass
Transport
Cleared$127.00$15,231.14
Fri, Nov 20$49.74+$18.50End of day balance $15,358.14
Refund · Amazon Marketplace
Shopping
Cleared+$18.50$15,358.14
Amazon Marketplace
Shopping
Cleared$42.99$15,339.64
Blue Bottle Coffee
Dining
Cleared$6.75$15,382.63
Thu, Nov 19$58.20+$500.00End of day balance $15,389.38
Transfer from Savings
Transfer
Cleared+$500.00$15,389.38
Shell Station 0442
Transport
Cleared$58.20$14,889.38
Wed, Nov 18$75.80End of day balance $14,947.58
Spotify
Subscriptions
Cleared$11.99$14,947.58
Corner Market
Groceries
Cleared$63.81$14,959.57
Tue, Nov 17$1,944.12+$4,125.00End of day balance $15,023.38
City Water & Power
Utilities
Cleared$94.12$15,023.38
Rent, 14 Alder St
Housing
Cleared$1,850.00$15,117.50
Northwind Payroll
Income
Cleared+$4,125.00$16,967.50

Day rows show that day’s debits, credits and closing balance. Pending transactions are listed but left out of the balance until they clear.

How it works

1.The balance is computed before the table sees the rows

A running balance belongs to the account, not to the view. The ledger walks every transaction oldest first and stamps each row with the balance after it, before TanStack filters or sorts anything. Searching, showing only money out or flipping the order changes which rows you see, never the numbers on them.

src/components/transactions/ledger.ts
ordered.forEach(({ t }, seq) => {
if (counts(t, includePending)) balance += t.amount
rows.push({ ...t, seq, balance: counts(t, includePending) ? balance : null })
})

2.One tbody per day

The sorted rows are split wherever the date changes, and each day gets its own tbody headed by a th with scope="rowgroup", so screen readers announce which day a row belongs to. The day row lines up with the columns below it: that day’s debits, credits and closing balance. Sorting by posting order keeps a day’s rows together in either direction.

src/components/transactions/data-table.tsx
<TableBody key={group.date}>
<TableRow>
<TableHead scope="rowgroup" colSpan={2}>{dayLabel(group.date, today)}</TableHead>
…

3.Debit and credit are two columns, not a sign

Amounts are stored as signed cents, which keeps the arithmetic exact, and split into Debit and Credit columns for display, the way bank statements read. Credits get a plus sign and the success color; every amount is right-aligned in tabular figures so the decimal points line up.

src/components/transactions/columns.tsx
cell: ({ row }) =>
row.original.amount < 0 ? <Amount cents={-row.original.amount} … /> : null

4.Pending is a state, not just a label

Pending transactions are listed with a dashed badge and muted amounts, but stay out of the running balance until they clear, which is how most banks show them. The switch counts them in, so you can see where the balance is heading. The summary follows the bank rule for available balance: pending debits are held at once, pending credits only count once they clear.

src/components/transactions/ledger.ts
available: current + sum(pending.filter((t) => t.amount < 0)),