Expense search
Natural-language search over card spend ("taxis over £50 last month"): a search box that runs on Enter, and results that show how the search was read (words matched by meaning, exact date, amount, currency and receipt filters), the match count and the matching expenses best first, with loading, empty and error states. Pass result (with loading and error) to render your own results 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-searchAlso installs: badge, button, input, base-theme, base-info-hint, base-states, expenses-table, ui-expenses-search.
Usage
import { ExpenseSearchResults } from "@/components/dolfin/expenses/expense-search";
// Place it anywhere inside your <DolfinProvider>.
<ExpenseSearchResults />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 |
|---|---|---|
query | string | The search to run. |
result | ExpenseSearchResult | A result you already hold: shown as given, nothing is fetched. |
loading | boolean | |
error | Error | |
onRetry | () => void | |
onClear | () => void | Shows "Clear results". |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the "Nothing matches" state. |
className | string | |
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. |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
base.infoHint.moreAboutbase.states.retrybase.states.staleErrorcore.errorsexpenses.expenses.search
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.
useDolfinLocaleuseExpenseSearchuseMessagesFiles
Written to your app by the install command:
components/dolfin/expenses/expense-search.tsx168 lines