Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Trial Banner Billing Block for React

A trial-ending banner for an app's shell: days left in the heading, a progress bar, what changes when the trial ends, an Add payment method action and a dismiss that remembers.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Tell people their trial is ending before it does, inside your app, with this trial banner for React with Base UI. A hairline frame with a plus mark on each corner holds a heading that carries the days left ("5 days left in your Osprey Mail trial"), a sentence on the end date and what happens next, and a dismiss button. Under it a Progress bar in your foreground color shows how many of the trial's days are used ("Day 9 of 14") beside the end date, and a Data List lays out what changes on that day: mailboxes, search history and shared inboxes. The one colored control is a Shine Button, "Add payment method". Dismissing hides the banner for the rest of the day, remembered in the browser, and leaves a line with a ghost Button to bring it back. The banner wraps on a phone and has a CSS entrance only. For the top of an app shell, a dashboard or a settings page.

FAQ

How do I fill it from my billing provider?

A TRIAL constant at the top of the file holds the plan's name, the whole daysLeft, the trial's length in days and the ISO endsOn date; the bar's fill is length - daysLeft days of length. CHANGES lists what moves to the free plan, one label and value each. Replace them with the subscription's trial dates, and pass them in as props if the shell fetches them. Mind your own time zone rules for "days left": the block only shows the number you give it.

How does the dismiss remember?

It writes today's date, in UTC, to the browser's local storage under osprey-mail:trial-banner-dismissed, and the banner stays hidden for the rest of that UTC day. The next day it shows again. A banner dismissed earlier today appears in the server's markup and hides right after the page loads, so it can show for a moment; if you read the dismissal on the server, pass it in and remove the effect. If the browser blocks storage, the banner stays hidden until the page reloads. Rename the key for your app.

Where does focus go when I dismiss it?

To the "Show it again" button that takes the banner's place, so a keyboard user isn't dropped at the top of the page. Pressing that button brings the banner back and puts focus on its dismiss button. The dismiss button is named "Dismiss the trial banner for today".

What does a screen reader hear?

The banner is headed by an h2 that reads as the days left. The bar only repeats "Day 9 of 14", which is on the page as text, so it is hidden from assistive technology rather than announced twice. What changes is a description list, so each value is read with its label, and the end date sits in a time element.

Where do the buttons go?

"Add payment method" is a link, so point it at your payment method page or checkout. It's a Shine Button with render set to an a element and nativeButton={false}. The dismiss and "Show it again" are buttons.

How does it look on a phone?

It's short: the heading starts near the top and the button sits within the first screen. The bar, the list of changes and the button stack in a column at full width, and the list wraps onto as many lines as it needs.

  • Pro

    Current Plan Billing

    Plan and usage

    The account's current plan in app settings: plan, price, renewal date and card, a change-plan action, every quota's usage this period on shared hairlines, and the next invoice.

  • Pro

    Limit Reached Billing

    Upsell and retention

    The upgrade prompt shown where someone hits a plan limit: what was blocked, the limit reached against the next plan's, a two-column comparison and Upgrade or Remind me later.

  • Pro

    Usage Meters Billing

    Plan and usage

    Usage meters for an app's settings: one row per quota with its count, a bar that turns to a warning tone at 80% and an over-limit tone past 100%, and a plain line on what happens next.

  • Pro

    The paywall itself: a spending report that turns blurred under a lock and an Unlock with Premium panel, with the Premium plan, its price and its button beside it and the Free plan under it.

  • Pro

    Money Back Hero Pricing

    Proof and guarantees

    One plan sold on its guarantee: an oversized 30-day seal, its promise written round the edge, beside the plan's price, features and call to action.

  • Pro

    Cancel Retention Billing

    Upsell and retention

    A cancel flow in three steps: a reason picker, an offer that matches it (half off for three months, or a pause), and a last page with the exact end date, each step taking focus and every outcome ending on a confirmation.