shadcn.io is not affiliated with official shadcn/ui
Discount Badge Billing Block for React
A yearly discount said three ways: a badge beside the Studio price reads as a percent, an amount saved or months free, and the arithmetic behind each is listed with the quoted line marked.
Installation
Overview
Say a discount the way your customers best understand it, with this discount badge for React with Base UI. A compact header sits over one hairline frame with a plus mark on each corner. The plan card shows the Studio price with the monthly price struck through, and an outline badge that is a button: pressing or focusing it opens a Hover Card on what the discount covers, the base plan and extra seats but not usage. A Toggle Group, Percent, Amount or Months free, rewrites the badge as "-20%", "Save $117.60 a year" or "2.4 months free". Under it a list shows the arithmetic: twelve months at $49.00, the percent, the amount (20% of $588.00), the months (the amount divided by the monthly price) and what you pay for the year. The line the badge quotes is marked with a bar and the words "on the badge". The only Shine Button, "Switch to yearly", sits in a foot with a status line. It's built from Hover Card, Toggle Group, Shine Button and Guides, with a CSS entrance only. For pricing settings, offers and checkout.
FAQ
How do I change the plan and the discount?
Edit PLAN at the top of the file: the monthly price in cents and the percent off, and RENEWS for the renewal date. The yearly price, the amount saved, the free months, the badge texts and every line of the arithmetic are derived from them, so a different discount needs no other change. Add a way to say it by adding a Phrasing and its text in badgeText.
Why three ways to say it?
The same saving reads differently by audience. A percent is quick to compare, an amount is concrete, and months free suits a plan billed monthly. The list under the card shows that all three come from one number, so whichever you choose never contradicts the price.
How does the card open?
What does Switch to yearly do, and what stays local?
It only says that yearly starts at your renewal in your app and that nothing was switched here, and the button then reads "Switch requested". In your app, send the choice to your billing provider in choose, change the plan at the renewal and show the provider's answer in the same status line.
Is it accessible?
The toggle group is named by its visible label and the pressed item is solid foreground, not colour alone. The struck-through price has a hidden "Was" and "a month" for screen readers, the marked line says "on the badge" in words, and the status line is a polite live region that is present from the start.