Upgrade prompt
Moment-of-value limit-reached upgrade card with a usage meter, rolling price, monthly/yearly billing toggle with savings badge, three concrete plan unlocks, and fixed-size offer, upgrading, error, success, and reminder states.
import { UpgradePrompt } from '@uthereal/ui/upgrade-prompt'Upgrade prompt playground
You’ve used all 50 AI credits
Your free AI credits reset Nov 1. Upgrade to keep going without the wait.
$16/ month
- 2,000 AI credits a month
- Claude Opus 5.5 and GPT-6.1 Sol
- Priority queue with no daily caps
Overview
UpgradePrompt appears at the moment a user hits or approaches a plan limit (AI credits, seats, generations, or storage). It names what ran out, displays a semantic usage meter, presents one next plan with a rolling price and Monthly / Yearly BillingToggle (including an automatic savings badge), lists concrete unlocks, and offers Upgrade alongside Maybe later.
Every state—offer, upgrading, error, success, and Maybe later—shares the same CSS grid cell with bottom-pinned actions so the card never changes size and buttons never jump. Upgrading resolves into the new limits table with the usage meter resettling against the upgraded allowance; Maybe later crossfades to a calm reset-date reminder with a one-click path back to the offer.
Use UpgradePrompt inside dialogs, popovers, or inline paywall slots when an action is blocked by a usage limit. For setting proactive budget alerts on metered spend, use Spend alert. For comparing model token costs before upgrading, use LLM cost calculator.
Usage
'use client'
import { UpgradePrompt } from '@uthereal/ui/upgrade-prompt'
export function OutOfCreditsPrompt({
used,
limit,
onClose,
onRetryAction,
}: {
used: number
limit: number
onClose: () => void
onRetryAction: () => void
}) {
return (
<UpgradePrompt
used={used}
limit={limit}
unit="AI credits"
resetsOn="Nov 1"
onUpgrade={async (selection, signal) => {
const res = await fetch('/api/billing/upgrade', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(selection),
signal,
})
if (!res.ok) {
const data = await res.json().catch(() => ({}))
throw new Error(
data.message ?? 'Your card was declined. Try another card.',
)
}
}}
onContinue={() => {
onClose()
onRetryAction()
}}
onDismiss={() => {
void fetch('/api/nudges/upgrade/snooze', { method: 'POST' })
}}
/>
)
}Omit onUpgrade to run a local simulated upgrade (simulatedUpgradeMs, default 1100ms) on explicit press—nothing runs on mount, and both the success copy and live-region announcements explicitly include simulatedNote ("Simulated, nothing is charged."). Always compute and charge the actual plan and interval on your server.
Examples
Team seats limit billed monthly
Configure used={5}, limit={5}, unit="seats", defaultInterval="monthly", and a custom plan for non-AI SaaS upsells where monthly billing is selected initially and copy derives automatically ("You’ve used all 5 seats").
You’ve used all 5 seats
Your free seats reset Nov 1. Upgrade to keep going without the wait.
$49/ month
- Up to 25 active workspace seats
- Custom approval flows and member roles
- 1-year version history and audit trail
Proactive near-limit nudge with model marks
Pass used below limit (42 of 50) to show the below-limit meter label ("8 left") and derived heading ("You’ve used 42 of 50 deep research runs"), paired with inline decorative anthropic and openai provider marks on unlock lines.
You’ve used 42 of 50 deep research runs
Your free deep research runs reset Nov 1. Upgrade to keep going without the wait.
$24/ month
- 500 deep research runs a month
- Claude Opus 5.5 extended synthesis
- GPT-6.1 Sol multi-hop verification
Card states and billing lifecycle
Fixed-size panel states
| Phase | Trigger | Visual and focus behavior |
|---|---|---|
offer | Initial state / See {plan} again | Displays rolling price, billing toggle, unlocks, Maybe later, and Upgrade to {plan}. |
upgrading | Upgrade pressed | Primary button enters loading state (stays focusable); billing toggle becomes inert; Maybe later disables. |
error | onUpgrade rejects | Inline danger message replaces the billing meta line; primary button switches to Try again. |
success | onUpgrade resolves (or simulated) | Header swaps to "You’re on {plan}", meter resettles against plan.limit in success tone, shows new limits. |
later | Maybe later pressed | Crossfades to the reset-date reminder with a See {plan} again button pinned in the same footer slot. |
Billing selection payload
onUpgrade(selection, signal) and onUpgraded(selection) receive an UpgradeSelection object:
plan:plan.name(for example,"Pro").interval:'monthly' | 'yearly'.amount:plan.price.monthlyon monthly billing, orplan.price.yearly * 12on yearly billing.currency: ISO 4217 code (plan.currency, default"USD").
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | string— | Heading of the card. Omit it to derive it from used, limit and unit, such as "You’ve used all 50 AI credits". |
description | string— | The line under the title. Omit it to derive it from unit and resetsOn, so it mentions the reset date. |
used | integerDefault: 50 | How much of the limit is used, such as 50. |
limit | integerDefault: 50 | The current plan’s limit. At or over it the meter reads Limit reached; below it, how many are left. |
unit | stringDefault: "AI credits" | What is counted, plural: "AI credits", "seats" or "generations". Used in the title, meter and announcements. |
resetsOn | stringDefault: "Nov 1" | When the current limit resets, such as "Nov 1". Shown in the description and the Maybe later reminder. |
plan | UpgradePlan— | The plan being offered: name, price.monthly and price.yearly (per month when billed yearly), ISO currency code, the new limit in the same unit as limit, the unlock lines and the new-limit rows listed after the upgrade. |
defaultInterval | monthly | yearlyDefault: "yearly" | Billing interval on mount when the React-only interval prop is left out: monthly or yearly (default). Edits do not reset a mounted instance. |
saveBadgeTemplate | stringDefault: "−{value}%" | Savings badge on the yearly toggle option. {value} fills the rounded percent, so "−{value}%" reads "−20%". |
upgradingLabel | stringDefault: "Upgrading" | Upgrade button label while the upgrade runs. |
tryAgainLabel | stringDefault: "Try again" | Upgrade button label after a failed upgrade. |
laterLabel | stringDefault: "Maybe later" | Quiet button that swaps the card to the calm reset-date reminder. |
continueLabel | stringDefault: "Continue" | Button on the success panel, usually wired to close the prompt and retry the blocked action. |
seeAgainTemplate | stringDefault: "See {plan} again" | Reminder panel button that returns to the offer. {plan} fills the plan name. |
limitReachedLabel | stringDefault: "Limit reached" | Meter status when the used count is at or over the limit. |
leftTemplate | stringDefault: "{value} left" | Meter status below the limit. {value} fills how many remain, such as "10 left". |
perMonthLabel | stringDefault: "/ month" | Unit after the price, "/ month" by default. |
billedMonthlyLabel | stringDefault: "Billed monthly. Cancel anytime." | Line under the price on the monthly interval. |
billedYearlyTemplate | stringDefault: "{value} billed yearly. Cancel anytime." | Line under the price on the yearly interval. {value} fills the yearly charge, such as "$192 billed yearly. Cancel anytime." |
billedTodayTemplate | stringDefault: "{value} billed today." | Success panel line. {value} fills the amount charged today. |
simulatedNote | stringDefault: "Simulated, nothing is charged." | Appended to the billed-today line and the announcements when no React upgrade callback is wired, so the demo never implies a real charge. |
successTitleTemplate | stringDefault: "You’re on {plan}" | Success panel title. {plan} fills the plan name. |
successDescription | stringDefault: "Your new limits are live. Pick up right where you left off." | Success panel line under the title. |
reminderTitleTemplate | stringDefault: "We’ll remind you {date}" | Reminder panel title. {date} fills the reset date, such as "We’ll remind you Nov 1". |
reminderBodyTemplate | stringDefault: "Your {unit} come back then, and everything you made stays put. {plan} is here whenever you need more." | Reminder panel body. {unit} fills what is counted and {plan} the plan name. |
upgradingAnnouncementTemplate | stringDefault: "Upgrading to {plan}." | Polite live-region announcement when the upgrade starts. {plan} fills the plan name. |
successAnnouncementTemplate | stringDefault: "You’re on {plan}. {value} {unit} a month." | Polite live-region announcement after the upgrade. {plan}, {value} and {unit} fill in, such as "You’re on Pro. 2,000 AI credits a month." |
dismissedAnnouncementTemplate | stringDefault: "Dismissed. Your {unit} reset {date}." | Polite live-region announcement on Maybe later. {unit} and {date} fill in. |
simulatedUpgradeMs | integerDefault: 1100 | How long the local simulated upgrade runs when no React upgrade callback is wired, in milliseconds. Nothing runs on mount. |
errorFallbackLabel | stringDefault: "The upgrade did not go through. Try again." | Error text when a failed upgrade callback reports no message of its own. |
upgradeAction | string— | Registered host action requested when Upgrade is pressed. The React-only onUpgrade callback owns the actual charge. |
dismissAction | string— | Registered host action requested when Maybe later is pressed; snooze the nudge here. |
continueAction | string— | Registered host action requested when Continue is pressed on the success panel. |
locale | string— | BCP 47 locale for the price, counts and percentages, such as "de-DE". Inherited from the provider when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | UpgradePromptTheme— | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | UpgradePromptMotionOptions— | Price roll, text swap, panel crossfade and meter fill overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
UpgradePlanaccepts{ name, price: { monthly, yearly }, currency, limit, features, limits }.price.yearlymust not exceedprice.monthly, and feature and limit row IDs must be unique.UpgradeFeatureaccepts{ id, label, mark?: 'none' | 'anthropic' | 'openai' | 'google' }.UpgradeLimitRowaccepts{ id, label, value }.
React integration
| Prop | Purpose |
|---|---|
interval / onIntervalChange | Controlled billing interval ('monthly' | 'yearly') and change callback fired in both controlled and uncontrolled modes. |
onUpgrade(selection, signal) | Async upgrade handler; resolve to enter success or reject with an Error to show its message inline. Aborted automatically on unmount. |
onUpgraded(selection) | Called once the upgrade resolves and the success panel is shown. |
onDismiss() | Called when Maybe later is pressed so the host can snooze the nudge. |
onContinue() | Called when Continue is pressed on the success panel; when omitted, pressing Continue resets the demo back to the offer. |
onAction(action, itemId?) | Called with upgradeAction, dismissAction, or continueAction when their corresponding buttons are pressed. |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme, forwarded to the root card, billing toggle, and buttons. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
Tab | Moves across the billing toggle, Maybe later, and Upgrade (or Continue / See again). |
ArrowLeft / ArrowRight | Switches between Monthly and Yearly inside the BillingToggle. |
Enter / Space | Activates the focused button. |
- The root
<section>is named by its heading (aria-labelledby). The usage bar exposesrole="meter"witharia-label={unit},aria-valuemin={0},aria-valuemax={currentLimit},aria-valuenow, and fullaria-valuetext("50 of 50 AI credits used"). - Animated
RollingNumberdigits are markedaria-hidden="true"and paired with a visually hidden plain-text price so screen readers read one currency value instead of separate digits. - Inactive panels and swapped copy receive
inert,aria-hidden="true", andvisibility: hiddenafter exit so keyboard focus and screen readers never reach hidden states. - During
upgrading, the primary Button usesloadingso focus stays on the button rather than dropping to<body>, while the billing toggle becomesinert. - A pre-mounted polite
role="status"live region announces upgrading, success with the new allowance (plus simulation note when local), dismissal reset date, and failure messages. - Container queries reduce padding below
420px, wrap the billing toggle cleanly under the price at narrow widths, and support full RTL (dir="rtl") including mirrored meter fill transforms.
Motion & theming
Switching intervals rolls changed digits in RollingNumber while swapping the billing subtitle (120ms out, 160ms in with a 2px rise). Transitioning between offer, success, and reminder panels crossfades in place (240ms enter with a 4px rise, 120ms exit) while the meter fill slides on the zero-bounce smooth spring (transform only so rounded ends never stretch).
Under prefers-reduced-motion: reduce, meter springs, digit rolling, rise travel, and blur turn off while text and panel swaps keep 120ms opacity crossfades. Setting motion="none" makes every swap, meter fill, price update, toggle slide, and button transition immediate (0ms).
theme accepts mode, accent, and typed tokens across these groups:
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-shadow, --ui-disabled-opacity, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength |
include | --ui-popup-radius |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, UpgradePrompt is a leaf block whose interval state persists across host updates. Present it when an action hits a limit rather than on initial page load, keep the three unlock lines specific to the blocked task, and wire upgradeAction, dismissAction, and continueAction to registered host actions. See Building with agents.
{
"type": "UpgradePrompt",
"props": {
"used": 50,
"limit": 50,
"unit": "AI credits",
"resetsOn": "Nov 1",
"defaultInterval": "yearly",
"upgradeAction": "upgrade_workspace_plan",
"dismissAction": "snooze_upgrade_prompt",
"continueAction": "retry_blocked_action"
},
"children": []
}