Expense headline tiles
Spend for the period against the previous one, Missing receipts, VAT reclaimable (with the estimate at risk) and Awaiting approval, for a period and whose spend. The receipt and approval tiles open their expenses views. Loading and error states, optional Ask agent buttons, and ExpensesStatCard for custom tiles. Pass kpis (with loading and error) to render your own figures without a request.
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-summary-cardsAlso installs: skeleton, base-theme, base-money, base-stat-card, base-states, ui-expenses-summary-cards, base-info-hint.
Usage
import { ExpensesSummaryCards } from "@/components/dolfin/expenses/summary-cards";
// Place it anywhere inside your <DolfinProvider>.
<ExpensesSummaryCards />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 |
|---|---|---|
tiles | readonly ExpensesSummaryTileKey[] | Which built-in tiles to show, in order. Defaults to Spend, Missing receipts, VAT reclaimable, Awaiting approval. |
extraTiles | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Custom tiles after the built-in ones; build them with `ExpensesStatCard`. A function gets the reports this component read (not called when you pass `kpis`). |
kpis | ExpensesHomeKpis | Figures you already hold (`deriveExpensesHomeKpis`): rendered as given and nothing is fetched. |
loading | boolean | |
error | Error | |
onRetry | () => void | |
onAskAgent | (prompt: string, tile: ExpensesSummaryTileKey) => void | Shows an Ask agent button on the Spend and VAT tiles; the prompt is the tile's question for an assistant. |
tileClassNames | StatCardClassNames | Per-part classes for every built-in tile (label, value, sub, ...). |
className | string | |
period | "Last7Days" | "Last30Days" | "Last90Days" | "MonthToDate" | "QuarterToDate" | "YearToDate" | "Last12Months" | Defaults to the last 30 days. |
scope | SpenderScope | Whose spend; defaults to everyone. `mine` needs a user session (an API key has no "me"). |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
base.statescore.errorsexpenses.home
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.
useExpensesHomeReportsuseMessagesFiles
Written to your app by the install command:
components/dolfin/expenses/summary-cards.tsx276 lines