@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

PropTypeDefaultDescription
yearnumberOverride the AssetProvider's year.
monthnumber | nullOverride 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.
periodsCashflowPeriodOverride[]Override fetched data (always two entries: previous, current). Each entry: { start, startingBalance, endingBalance, changeInCash? }.
state"loading" | "error"Force a specific state for testing.
lockedbooleanGate 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.
childrenrequiredReactNodeCompound parts.

Parts

Container

Always rendered. Provides data and context to its children.

PartDescription
CashflowCard.RootFetches period data and provides context.

Success

Renders when period data is available.

PartDescription
CashflowCard.SuccessState wrapper. Compose the period table inside.
CashflowCard.PeriodsRenders its children once per period, within a per-period context.
CashflowCard.PeriodLabel
asChild?, format?
Renders the current period's label (default: "Apr 2026" for month, "2026" for year). Pass format(start, granularity) to override.
CashflowCard.StartingBalance
asChild?
Starting balance for the current period.
CashflowCard.EndingBalance
asChild?
Ending balance for the current period.
CashflowCard.ChangeInCash
asChild?
Net change in cash for the current period.
CashflowCard.Tone
asChild?
Wrapper that adds data-tone to its child based on the sign of the change.

Loading

Renders while the fetch is in flight.

PartDescription
CashflowCard.LoadingState wrapper. Render any skeleton or placeholder UI inside.

Empty

Renders when the fetch succeeded but returned no periods.

PartDescription
CashflowCard.EmptyState wrapper. Render an empty-state message inside.

Error

Renders when the fetch fails.

PartDescription
CashflowCard.ErrorState wrapper. Compose the error UI inside.
CashflowCard.ErrorMessage
asChild?
Renders the error's message string.
CashflowCard.Retry
asChild?
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.

PartDescription
CashflowCard.LockedState wrapper. Compose the upgrade / upsell UI inside — see LockedUpsell.

Unlocked

Renders whenever the card is NOT locked — the inverse of Locked.

PartDescription
CashflowCard.UnlockedState wrapper. Renders children whenever the card isn't locked.

Hooks

PartDescription
useCashflowCard()Hook returning data, loading, error, locked, retry.
useCashflowPeriod()Hook for components inside a Periods iteration; returns the active period.