Expenses table
Card spend, most recent first: merchant with its category and the card's own spelling, who spent it, the card, the date, status with the flag as the thing to do, receipt presence and amount. Rows link to the expense. Cursor paging and an empty state for each view (nothing stuck, nothing to approve, every receipt in, no spend for this person, nothing for these filters), plus loading and error states. Fetches by filters or merchant, or shows the expenses you pass (with loading, error and paging props) and fetches nothing. Configurable columns and row actions; ExpenseRowsTable renders rows the caller already has (search results).
Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. Pages vs components
Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.
Installation
Needs the Dolfin registry token. The CLI copies the source into your app.
bunx --bun shadcn@4.23.0 add @dolfin/expenses-tableAlso installs: badge, button, base-theme, base-data-table, base-entity-cell, base-money, base-states, expenses-status, ui-expenses-table.
Usage
import { ExpensesTable } from "@/components/dolfin/expenses/expenses-table";
// Place it anywhere inside your <DolfinProvider>.
<ExpensesTable />Renders inside DolfinProvider (set it up once). By default it loads its own data through the SDK. Supplied-data examples show how to override that behavior.
API reference
| Prop | Type | Description |
|---|---|---|
filters | ExpenseListFilters | Fetches the expenses matching these filters. |
merchantId | string | Fetches the expenses made at this merchant (adds `merchantId` to `filters`). |
pageSize | number | Expenses per page when the table fetches. |
expenses | readonly { id?: string; organisationId?: string; cardConnectionId?: string; cardLast4?: null | string; cardNetwork?: null | string; cardDisp… | Your expenses. Passing `expenses`, `loading` or `error` means the table fetches nothing. |
loading | boolean | With no expenses yet, the loading state; with expenses on screen, a refresh cue. |
error | Error | |
onRetry | () => void | Shows "Try again" in the error state. |
page | number | The page on screen, from 1. |
hasNextPage | boolean | |
onPageChange | (page: number) => void | Shows the pager; called with the page to show. |
emptyKind | ExpenseListEmptyKind | Which empty state to show. Worked out from `filters` when not given. |
spenderLabel | string | Names the person in the "No spend for this person" empty state. |
onClearFilters | () => void | Shows "Clear filters" in the filtered empty state. |
onCountChange | (count: number) => void | Reports the number of expenses on the current page. |
columns | Columns | Replace or extend the default columns (merchant, spent by, card, date, status, receipt, amount). |
columnOrder | readonly string[] | |
columnVisibility | Readonly<Partial<Record<string, boolean>>> | |
rowActions | RowActions | Menu entries per row. None by default: the row itself opens the expense. |
className | string | |
variant | DataTableVariant | |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | |
onRowClick | (expense: Expense) => void | Called when a row is clicked; given, it replaces the row's link. |
getRowRoute | (expense: Expense) => DolfinRoute | null | Where a row leads. Defaults to the expense page. |
classNames | DataTableClassNames | |
pager | boolean | Show the built-in previous / next pager when there is more than one page. Default true; pass false when you draw your own pager from the list's pagination (the table still dims while a page loads). |
onRowHover | (row: { id?: string; organisationId?: string; cardConnectionId?: string; cardLast4?: null | string; cardNetwork?: null | string; cardDisplay… | Called with the row the pointer moves onto, and with `null` when the pointer leaves the rows (e.g. to highlight the row's point in a chart next to the table). Moving between rows reports the new row without a `null` first. |
sort | DataTableSort | |
onSortChange | (sort: DataTableSort | null) => void |
Customisation
Without editing the source, you can change:
- Class names
classNameclassNames.frameclassNames.headerclassNames.headerCellclassNames.rowclassNames.cellclassNames.pager- Messages
expenses.expenses
Or edit the installed file directly: it is your code. See theming for colours and fonts.
Hooks
The SDK hooks this component uses. Use them directly from @dolfinai/react to build your own version.
useDolfinLocaleuseExpensesuseMessagesFiles
Written to your app by the install command:
components/dolfin/expenses/expenses-table.tsx326 linescomponents/dolfin/expenses/expenses-table-cells.tsx173 lines