Upgrade prompt

The panel shown when an allowance is nearly or wholly used: a usage meter, a headline for where the reader stands, what the next plan adds, and the way to it.

Upgrade prompt

Plain Blade, no script, including its close control.

Use it

@if ($team->credits_used >= $team->credits_limit * 0.8)
    <x-ds::upgrade-prompt
        label="AI credits"
        :used="$team->credits_used"
        :limit="$team->credits_limit"
        unit="credits"
        plan="Pro"
        :href="route('billing.upgrade', 'pro')"
        :secondaryHref="route('pricing')"
        :benefits="['2,000 credits a month', 'Longer documents', 'Priority support']"
    >
        You have used most of this month's credits.
    </x-ds::upgrade-prompt>
@endif

Variants

  • card (default): a bordered panel, for the top of a page or a sidebar.
  • inline: no box, for inside a section that already has one, such as a settings panel.
  • gate: stands where locked content would be. A dimmed placeholder fills the space and the prompt sits over it, centred.

The gate never holds the locked content

@can('use', $feature)
    <x-reports.builder />
@else
    <x-ds::upgrade-prompt variant="gate" label="Reports" :used="3" :limit="3" plan="Pro" :href="route('billing')">
        <x-slot:placeholder><x-ds::skeleton variant="block" size="lg" /></x-slot:placeholder>
        Reports past three a month are on Pro.
    </x-ds::upgrade-prompt>
@endcan

The content behind a gate is not rendered: you leave it out, as above. Blurring real content is not a lock; the data is in the page source and in the accessibility tree. The placeholder slot is for a picture of the feature, a skeleton or a screenshot, and it is aria-hidden and inert. Without the slot it is a few still bars.

Props

PropTypeDefaultWhat it does
variantcard inline gatecardSee above.
labelstring—What is used up, as the meter's label. Required.
usednumber—How much has been used. Required.
limitnumber—The allowance. Required.
unitstring—The noun after the numbers.
warnAtint80Percent of the limit at which the meter turns warning.
planstring—The plan to upgrade to: names the action "Upgrade to Pro".
hrefstring—Where the upgrade happens. Draws the primary action.
actionLabelstringUpgrade to {plan}, or UpgradeThe primary action's words.
secondaryHrefstring—A second link.
secondaryLabelstringCompare plansIts words.
benefitsarray of strings[]What the plan adds, each with a tick.
nearTitlestringYou are close to your limitHeadline under the limit.
atTitlestringYou have reached your limitHeadline at it.
overTitlestringYou are over your limitHeadline past it.
iconstringsparklesThe mark beside the headline.
dismissibleboolfalseA close control, for card and inline (never on a gate, which would leave a hole).
Slot
defaultA line under the headline.
placeholderWith gate: the dimmed picture behind the prompt.

States

The state comes from the numbers, the way usage meter colours its bar: over past the limit, at on it, and near anything under, since you show the prompt only once the reader is getting close. Near is warning; at and over are danger. Each has its own headline, so the words say it as well as the colour.

Dismissing

The ✕ is a plain handler, as alert's is: it works in a page with no script, dispatches dismiss from the prompt, and removes it. To keep it away, listen and remember it on the server:

<x-ds::upgrade-prompt … :dismissible="true" x-on:dismiss="$wire.snoozeUpgrade()" />

Accessibility

  • It is a section named by its headline, so it is listed among a screen reader's regions with its state in its name.
  • The meter is a meter with its value in words, over the limit included.
  • The gate's placeholder is aria-hidden and inert: nothing in it is read or reached.

Don't

  • Don't show it under the threshold. A prompt on every page is an advert, and readers learn to skip it.
  • Don't lock with CSS. Render the gate instead of the content.
  • Don't hide the way out. The page around a gate should still work.

More in specs/upgrade-prompt.md.


From the package repo: edit this page on GitHub.

Was this page helpful?