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.
Installation
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.
Related
- Pro
Current Plan Billing
Plan and usageThe 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 retentionThe 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 usageUsage 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
Freemium Gate Pricing
Single planThe 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.
- 30Pro
Money Back Hero Pricing
Proof and guaranteesOne 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 retentionA 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.