@get-asset/sdk

RevenueCard

Headless compound that fetches a period's revenue and the prior-period baseline, exposing the value, percent change, and tone as composable parts. Period defaults to the AssetProvider's year/month.

Anatomy

Import the primitive and compose the parts you need.

<RevenueCard.Root year={2026}>
<RevenueCard.Loading></RevenueCard.Loading>
<RevenueCard.Error>
<RevenueCard.ErrorMessage />
<RevenueCard.Retry />
</RevenueCard.Error>
<RevenueCard.Success>
<RevenueCard.Period />
<RevenueCard.Revenue />
<RevenueCard.Change />
<RevenueCard.Tone>{/* data-tone="positive" */}</RevenueCard.Tone>
</RevenueCard.Success>
</RevenueCard.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 to report on. 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. Skips the API call.
previousRevenuenumberOverride fetched prior-period revenue.
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
RevenueCard.RootFetches the current and previous period P&L and provides context.

Success

Renders children when revenue is available.

PartDescription
RevenueCard.SuccessState wrapper. Compose the value UI inside.
RevenueCard.Period
asChild?
Renders the resolved period — defaults to MMM YYYY or YYYY. Pass format(year, month) to override.
RevenueCard.Revenue
asChild?
Renders the current-year revenue value.
RevenueCard.Change
asChild?
Renders the period-over-period percent change.
RevenueCard.Tone
asChild?
Wrapper that adds data-tone="positive" | "negative" | "neutral" to its child for styling.

Loading

Renders children only while the fetch is in flight.

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

Error

Renders children when the fetch fails.

PartDescription
RevenueCard.ErrorState wrapper. Compose the error UI inside.
RevenueCard.ErrorMessage
asChild?
Renders the error's message string.
RevenueCard.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
RevenueCard.LockedState wrapper. Compose the upgrade / upsell UI inside — see LockedUpsell.

Unlocked

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

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

Hooks

PartDescription
useRevenueCard()Hook returning the full context value (year, revenue, change, tone, loading, error, locked, retry).