Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Discount Badge Billing Block for React Aria

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.

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

Say a discount the way your customers best understand it, with this discount badge for React with React Aria. 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?

The block controls the card itself so it opens on hover, on focus and on a tap on a touch screen, and closes on Escape or when focus leaves the badge.The card holds no controls, and the badge is a real button named with its text.

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.

How does it look on a phone?

The badge moves under the price, the three choices share one row, the arithmetic stays a list, and the status line and the button stay pinned in a foot at the bottom of the screen.