@get-asset/sdk

SnapshotCard

Headless compound for a quick revenue vs. expense snapshot with net profit and period-over-period change. Includes proportional bar parts so you can render comparisons without a chart library. Period defaults to the AssetProvider's year/month — pass a month to show that month vs. the previous month, omit it to show the full year vs. the previous year.

Anatomy

Import the primitive and compose the parts you need.

<SnapshotCard.Root year={2026}>
<SnapshotCard.Success>
<SnapshotCard.Period />
<SnapshotCard.NetProfit />
<SnapshotCard.Tone>
<SnapshotCard.Change />
</SnapshotCard.Tone>
<SnapshotCard.Revenue />
<SnapshotCard.RevenueBar />
<SnapshotCard.Expense />
<SnapshotCard.ExpenseBar />
</SnapshotCard.Success>
</SnapshotCard.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
yearnumberFiscal year. Falls back to the AssetProvider's year.
monthnumber | nullMonth (1-12). When set the card shows that month vs. the previous month; null explicitly forces a whole-year range. Falls back to the AssetProvider's month (default: no month).
revenuenumberOverride fetched revenue.
expensenumberOverride fetched expense. Provide as a positive number.
previousNetProfitnumberOverride prior-period net profit (drives the % change badge).
scalenumberOverride the +/- bound for the bar chart scale.
state"loading" | "error" | "empty"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
SnapshotCard.RootFetches revenue/expense totals and provides context.

Success

Renders when data is available.

PartDescription
SnapshotCard.SuccessState wrapper. Compose the snapshot UI inside.
SnapshotCard.Period
asChild?
Renders the resolved period — defaults to MMM YYYY or YYYY. Pass format(year, month) to override.
SnapshotCard.NetProfit
asChild?
Renders revenue − expense.
SnapshotCard.Revenue
asChild?
Renders the revenue value.
SnapshotCard.Expense
asChild?
Renders the expense value.
SnapshotCard.Change
asChild?
Percent change vs. previousNetProfit.
SnapshotCard.Tone
asChild?
Adds data-tone to its child based on the sign of the change.
SnapshotCard.RevenueBar
style?, className?
Proportional bar sized by revenue / scale. Renders a filled track.
SnapshotCard.ExpenseBar
style?, className?
Proportional bar sized by expense / scale.

Loading

Renders while the fetch is in flight.

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

Empty

Renders when the period has zero revenue and expense.

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

Error

Renders on fetch error.

PartDescription
SnapshotCard.ErrorState wrapper. Compose the error UI inside.
SnapshotCard.ErrorMessage
asChild?
Renders the error message string.
SnapshotCard.Retry
asChild?
Button that re-runs the fetch.

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
SnapshotCard.LockedState wrapper. Compose the upgrade / upsell UI inside — see LockedUpsell.

Unlocked

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

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

Hooks

PartDescription
useSnapshotCard()Hook returning the full context, including locked.