UI

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.

Limit reached50 of 50

$16/ month

$192 billed yearly. Cancel anytime.

  • 2,000 AI credits a month
  • Claude Opus 5.5 and GPT-6.1 Sol
  • Priority queue with no daily caps
Loading interactive preview…

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.

Limit reached5 of 5

$49/ month

Billed monthly. Cancel anytime.

  • 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.

8 left42 of 50

$24/ month

$288 billed yearly. Cancel anytime.

  • 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

PhaseTriggerVisual and focus behavior
offerInitial state / See {plan} againDisplays rolling price, billing toggle, unlocks, Maybe later, and Upgrade to {plan}.
upgradingUpgrade pressedPrimary button enters loading state (stays focusable); billing toggle becomes inert; Maybe later disables.
erroronUpgrade rejectsInline danger message replaces the billing meta line; primary button switches to Try again.
successonUpgrade resolves (or simulated)Header swaps to "You’re on {plan}", meter resettles against plan.limit in success tone, shows new limits.
laterMaybe later pressedCrossfades 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.monthly on monthly billing, or plan.price.yearly * 12 on yearly billing.
  • currency: ISO 4217 code (plan.currency, default "USD").

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
titlestring—Heading of the card. Omit it to derive it from used, limit and unit, such as "You’ve used all 50 AI credits".
descriptionstring—The line under the title. Omit it to derive it from unit and resetsOn, so it mentions the reset date.
usedintegerDefault: 50How much of the limit is used, such as 50.
limitintegerDefault: 50The current plan’s limit. At or over it the meter reads Limit reached; below it, how many are left.
unitstringDefault: "AI credits"What is counted, plural: "AI credits", "seats" or "generations". Used in the title, meter and announcements.
resetsOnstringDefault: "Nov 1"When the current limit resets, such as "Nov 1". Shown in the description and the Maybe later reminder.
planUpgradePlan—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.
defaultIntervalmonthly | 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.
saveBadgeTemplatestringDefault: "−{value}%"Savings badge on the yearly toggle option. {value} fills the rounded percent, so "−{value}%" reads "−20%".
upgradingLabelstringDefault: "Upgrading"Upgrade button label while the upgrade runs.
tryAgainLabelstringDefault: "Try again"Upgrade button label after a failed upgrade.
laterLabelstringDefault: "Maybe later"Quiet button that swaps the card to the calm reset-date reminder.
continueLabelstringDefault: "Continue"Button on the success panel, usually wired to close the prompt and retry the blocked action.
seeAgainTemplatestringDefault: "See {plan} again"Reminder panel button that returns to the offer. {plan} fills the plan name.
limitReachedLabelstringDefault: "Limit reached"Meter status when the used count is at or over the limit.
leftTemplatestringDefault: "{value} left"Meter status below the limit. {value} fills how many remain, such as "10 left".
perMonthLabelstringDefault: "/ month"Unit after the price, "/ month" by default.
billedMonthlyLabelstringDefault: "Billed monthly. Cancel anytime."Line under the price on the monthly interval.
billedYearlyTemplatestringDefault: "{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."
billedTodayTemplatestringDefault: "{value} billed today."Success panel line. {value} fills the amount charged today.
simulatedNotestringDefault: "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.
successTitleTemplatestringDefault: "You’re on {plan}"Success panel title. {plan} fills the plan name.
successDescriptionstringDefault: "Your new limits are live. Pick up right where you left off."Success panel line under the title.
reminderTitleTemplatestringDefault: "We’ll remind you {date}"Reminder panel title. {date} fills the reset date, such as "We’ll remind you Nov 1".
reminderBodyTemplatestringDefault: "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.
upgradingAnnouncementTemplatestringDefault: "Upgrading to {plan}."Polite live-region announcement when the upgrade starts. {plan} fills the plan name.
successAnnouncementTemplatestringDefault: "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."
dismissedAnnouncementTemplatestringDefault: "Dismissed. Your {unit} reset {date}."Polite live-region announcement on Maybe later. {unit} and {date} fill in.
simulatedUpgradeMsintegerDefault: 1100How long the local simulated upgrade runs when no React upgrade callback is wired, in milliseconds. Nothing runs on mount.
errorFallbackLabelstringDefault: "The upgrade did not go through. Try again."Error text when a failed upgrade callback reports no message of its own.
upgradeActionstring—Registered host action requested when Upgrade is pressed. The React-only onUpgrade callback owns the actual charge.
dismissActionstring—Registered host action requested when Maybe later is pressed; snooze the nudge here.
continueActionstring—Registered host action requested when Continue is pressed on the success panel.
localestring—BCP 47 locale for the price, counts and percentages, such as "de-DE". Inherited from the provider when omitted.
recipestudio | softDefault: "studio"Visual treatment. Both recipes preserve interaction behavior.
themeUpgradePromptTheme—Color mode, accent, and typed semantic token overrides.
motionnone | subtle | expressiveDefault: "subtle"Animation preset. System reduced-motion preferences take precedence.
motionOptionsUpgradePromptMotionOptions—Price roll, text swap, panel crossfade and meter fill overrides in milliseconds.
dirltr | rtl—Reading direction; inherited from the page when omitted.
  • UpgradePlan accepts { name, price: { monthly, yearly }, currency, limit, features, limits }. price.yearly must not exceed price.monthly, and feature and limit row IDs must be unique.
  • UpgradeFeature accepts { id, label, mark?: 'none' | 'anthropic' | 'openai' | 'google' }.
  • UpgradeLimitRow accepts { id, label, value }.

React integration

PropPurpose
interval / onIntervalChangeControlled 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.
presetApplication defaults overridden by explicit instance arguments.
tokensCSS variables applied after the typed theme, forwarded to the root card, billing toggle, and buttons.
ref, className, styleApplied to the root <section> element.
Native attributesid, aria-*, data-*, and remaining <section> props forwarded to the root element.

Keyboard & accessibility

KeyAction
TabMoves across the billing toggle, Maybe later, and Upgrade (or Continue / See again).
ArrowLeft / ArrowRightSwitches between Monthly and Yearly inside the BillingToggle.
Enter / SpaceActivates the focused button.
  • The root <section> is named by its heading (aria-labelledby). The usage bar exposes role="meter" with aria-label={unit}, aria-valuemin={0}, aria-valuemax={currentLimit}, aria-valuenow, and full aria-valuetext ("50 of 50 AI credits used").
  • Animated RollingNumber digits are marked aria-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", and visibility: hidden after exit so keyboard focus and screen readers never reach hidden states.
  • During upgrading, the primary Button uses loading so focus stays on the button rather than dropping to <body>, while the billing toggle becomes inert.
  • 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 groupCSS 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": []
}

On this page