@get-asset/sdk
CashflowCard
Headless compound rendering starting and ending bank balances for two periods, with the net change in cash for each. Periods are derived from the AssetProvider's year/month: with a month set, the prior month and the selected month; with no month, the prior year and the selected year.
Anatomy
Import the primitive and compose the parts you need.
<CashflowCard.Root><CashflowCard.Success><CashflowCard.Periods>{/* one render per period — always two: previous + current */}<CashflowCard.PeriodLabel /><CashflowCard.StartingBalance /><CashflowCard.EndingBalance /><CashflowCard.Tone><CashflowCard.ChangeInCash /></CashflowCard.Tone></CashflowCard.Periods></CashflowCard.Success><CashflowCard.Loading>…</CashflowCard.Loading><CashflowCard.Empty>No cashflow data yet.</CashflowCard.Empty></CashflowCard.Root>
Required scopes
The access token used by AssetProvider must include this scope for this primitive to fetch data successfully:
report:read
API reference
Root props
| Prop | Type | Default | Description |
|---|---|---|---|
year | number | — | Override the AssetProvider's year. |
month | number | null | — | Override the AssetProvider's month (1-12). When set, the card shows that month vs. the previous month; null forces a year-vs-prior-year comparison. Omit to inherit from the provider. |
periods | CashflowPeriodOverride[] | — | Override fetched data (always two entries: previous, current). Each entry: { start, startingBalance, endingBalance, changeInCash? }. |
state | "loading" | "error" | — | Force a specific state for testing. |
locked | boolean | — | Gate the report for an unentitled viewer. Activates the Locked state and skips the API fetch. See /docs/sdk/locked-upsell. |
upsell | { title?, description?, ctaLabel?, onUpgrade? } | — | Locked-state copy + upgrade handler; merged field-by-field over the card's default copy, then the generic fallback. |
childrenrequired | ReactNode | — | Compound parts. |
Parts
Container
Always rendered. Provides data and context to its children.
| Part | Description |
|---|---|
CashflowCard.Root | Fetches period data and provides context. |
Success
Renders when period data is available.
| Part | Description |
|---|---|
CashflowCard.Success | State wrapper. Compose the period table inside. |
CashflowCard.Periods | Renders its children once per period, within a per-period context. |
CashflowCard.PeriodLabelasChild?, format? | Renders the current period's label (default: "Apr 2026" for month, "2026" for year). Pass format(start, granularity) to override. |
CashflowCard.StartingBalanceasChild? | Starting balance for the current period. |
CashflowCard.EndingBalanceasChild? | Ending balance for the current period. |
CashflowCard.ChangeInCashasChild? | Net change in cash for the current period. |
CashflowCard.ToneasChild? | Wrapper that adds data-tone to its child based on the sign of the change. |
Loading
Renders while the fetch is in flight.
| Part | Description |
|---|---|
CashflowCard.Loading | State wrapper. Render any skeleton or placeholder UI inside. |
Empty
Renders when the fetch succeeded but returned no periods.
| Part | Description |
|---|---|
CashflowCard.Empty | State wrapper. Render an empty-state message inside. |
Error
Renders when the fetch fails.
| Part | Description |
|---|---|
CashflowCard.Error | State wrapper. Compose the error UI inside. |
CashflowCard.ErrorMessageasChild? | Renders the error's message string. |
CashflowCard.RetryasChild? | Button that re-runs the fetch on click. |
Locked
Renders when `locked` is set — the viewer isn't entitled to the report. Mutually exclusive with the other states, and no data is fetched. See the Locked / upsell guide for composing the teaser + upgrade UI.
| Part | Description |
|---|---|
CashflowCard.Locked | State wrapper. Compose the upgrade / upsell UI inside — see LockedUpsell. |
Unlocked
Renders whenever the card is NOT locked — the inverse of Locked.
| Part | Description |
|---|---|
CashflowCard.Unlocked | State wrapper. Renders children whenever the card isn't locked. |
Hooks
| Part | Description |
|---|---|
useCashflowCard() | Hook returning data, loading, error, locked, retry. |
useCashflowPeriod() | Hook for components inside a Periods iteration; returns the active period. |