Payables stat tiles
To pay, Overdue and Paid in the last 30 days, each with an explanation, multi-currency detail and trend, plus loading, empty and error states. ApStatCard builds custom tiles from the same figures.
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/ap-stats-cardsAlso installs: button, skeleton, base-theme, base-money, base-stat-card, base-states, ui-ap-stats-cards, base-info-hint.
Usage
import { ApStatsCards } from "@/components/dolfin/ap/stats-cards";
// Place it anywhere inside your <DolfinProvider>.
<ApStatsCards />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 |
|---|---|---|
stats | Partial<ApStatsFigures> | The figures to show (`toPay`, `overdue`, `paid`, `isEmpty`, ...). Passing them (or `loading` / `error`) fetches nothing; leave all three out and the tiles read the payables overview themselves. |
loading | boolean | |
error | Error | With figures shown, a quiet "some figures failed" line; with none, the error state. |
onRetry | () => void | |
tiles | readonly ApStatTileKey[] | Which built-in tiles to show, in order. Defaults to To pay, Overdue, Paid. |
extraTiles | (stats: Partial<ApStatsFigures>) => ReactNode | Custom tiles after the built-in ones; build them with `ApStatCard` from the same figures. |
onAskAgent | (prompt: string, tile: ApStatTileKey) => void | Shows an Ask agent button on each tile; the prompt is the tile's question for an assistant. |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the empty state (no bills at all). Pass `false` to show the tiles at zero instead. |
onSelectTile | (tile: ApStatTileKey) => void | Makes the built-in tiles toggles, e.g. to filter the bills list by the tile picked. |
selectedTile | ApStatTileKey | The tile shown as picked (`aria-pressed`). |
tileClassNames | StatCardClassNames | Per-part classes for every built-in tile (label, value, sub, ...). |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ap.homebase.statescore.errors
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.
useApStatsuseMessagesFiles
Written to your app by the install command:
components/dolfin/ap/stats-cards.tsx283 lines