dolfindevelopers

Category account picker

ComponentExpensesSDK + UI

Picks the account a merchant category, expense or card codes to, from the organisation's spend accounts (or accounts you pass), with Create an account as the last option: it opens the create dialog and picks the new account, or calls your own handler. Loading, busy and needs-attention looks.

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

Choose your integration

Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.

Loading preview…

Installation

Needs the Dolfin registry token. The CLI copies the source into your app.

Terminal
bunx --bun shadcn@4.23.0 add @dolfin/expenses-category-account-picker

Also installs: select, expenses-category-account-dialog, base-theme, ui-expenses-category-account-picker.

Usage

screen.tsx
import { CategoryAccountPicker } from "@/components/dolfin/expenses/category-account-picker";

// Place it anywhere inside your <DolfinProvider>.
<CategoryAccountPicker onChange={handleChange} />

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

PropTypeDescription
onChange required(ledgerAccountId: string) => void
valuestringThe chosen account id.
valueLabelstringShown when `value` is not among the accounts (e.g. an account since deactivated).
accountsreadonly MccLedgerAccount[]The accounts to offer; the organisation's spend accounts by default.
labelstringNames what the picker is for, for screen readers ("Account for Restaurants").
blockingbooleanOutlines the picker as the thing holding spend back (an unmapped category).
disabledboolean
submittingbooleanA save for this choice is running.
allowCreatebooleanOffer "Create an account..." last. With `onCreate` the host opens its own dialog; otherwise the picker opens the create dialog itself and picks the new account. Pass `false` to hide it. Defaults to true.
onCreate() => void
createPurposeCategoryAccountPurposeWhat the new account is for, which sets the dialog's copy. Defaults to "expense".
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
expenses.merchants.account

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.

useMccAccountsuseMessages

Files

Written to your app by the install command:

  • components/dolfin/expenses/category-account-picker.tsx 98 lines