shadcn.io is not affiliated with official shadcn/ui
Billing Toggle Pricing Block for React
Three plan cards under a monthly and yearly switch that wears its saving in the header row, with prices that roll to their new amount and each plan a card in a card.
Installation
Overview
Switch between monthly and yearly pricing with this three-plan billing toggle section, shown for Trestle Forms, a form and survey builder. The switch is the feature: it sits in the header row, its Yearly side marked with the saving it brings (a Segment Group with a highlight that slides to the choice), and every price rolls to its new amount with Sliding Number. Under each price a line says what yearly billing saves that plan in dollars. Each plan is a card in a card: its price and Shine Button call to action sit on a raised Frame panel, with the feature list below. The section sits on the page's drafting lines, drawn by Guides: rails at the edges of the page column that continue into the blocks above and below, a rule along its top edge with a plus on each crossing, and a band ruled top and bottom around the plans with a plus at its four corners. The featured Plus plan stands a little taller, with a Most popular badge and the only primary button. Below lg one plan shows at a time, picked from a second Segment Group, with its features cut after five. Built with Frame, Guides, Badge, Button, Segment Group, Sliding Number, Shine Button and Lucide icons, with CSS transitions only. For SaaS pricing pages, free-versus-paid ladders and subscription products.
FAQ
How do I change the plans, prices and the saving?
Edit the PLANS array at the top of the file. Each plan has its name, icon (a Lucide icon), description, monthly price, yearly price (the monthly amount when billed yearly), features with their featureHeading, the call to action's cta label and href, featured and an optional badge. The saving is never typed: savedOf works each plan's dollars out from its two prices, and the switch's mark and the headline show the largest percentage, so they stay right when a price changes. CURRENCY is the symbol written before every price. The billing state starts at "monthly"; start it at "yearly" to open on the lower prices.
How do I connect the plan buttons to checkout?
Each call to action is a real link to its plan's href. It's a ShineButton with render set to an a element and nativeButton={false}. Point href at your checkout or sign-up route and add the billing period to it, for example /checkout?plan=plus&billing=yearly, then let your server map the plan and period to your payment provider's price.
Is the billing toggle accessible?
Yes. The switch is a SegmentGroup, a radio group named "Billing period": Tab reaches the selected period and the arrow keys move and select. The Yearly side reads "Yearly, saves 20%": the visible minus sign is hidden from screen readers in favour of those words. Each price keeps its current amount in text and isn't a live region, so changing the period doesn't interrupt a screen reader. Plans are h3 headings under the section's h2, features are lists, and each call to action names its plan, as in "Start 14-day trial, Plus plan".
Why doesn't the layout jump when the period changes?
The digits are tabular (tabular-nums), so a price keeps its width as it rolls, and the line under it keeps its room for both periods ("Billed monthly. Yearly saves $36." and "Billed at $144 a year. Saves $36."). On wide screens the three cards share their rows through CSS subgrid, so the raised panels and the feature lists start on the same lines and the buttons line up whatever the descriptions' lengths. Under reduced motion the digits change in place and the cards appear without their entrance.
How does it work on a phone?
Below lg one plan shows at a time. A Plan switch under the header (a radio group named "Plan", Plus selected first) chooses which; the others are made invisible but keep their room, so nothing in them takes focus and switching plans moves nothing below. Each card's feature list is cut after five items, with a button ("All 7 features") that has aria-expanded and opens the rest. The call to action sits above the list, so it lands within the first screen and a half of an iPhone.
How do I feature another plan, or none?
Move featured: true and the badge to that plan, or set featured to false on every plan. The featured plan's button is the default (primary) variant and the others are outline, so the theme's colour marks one action. On wide screens the featured card also runs a little past the others at the top and bottom, its shell is bg-muted/50 and its raised panel casts a stronger shadow. The plan that is selected first on a phone is the featured one.
When should I use a billing toggle instead of separate monthly and yearly sections?
Use a toggle when only the price changes between periods: visitors compare both in place and the page stays short. Show separate sections, or a comparison table, when yearly plans come with different features or terms, so nothing that differs hides behind the switch.
Related
- Pro
Three Columns Pricing
Plan cardsThe canonical three-column pricing section for a team knowledge base: Personal, Team and Company cells under a monthly and yearly switch, each outlined by hairlines that overshoot its corners, the recommended plan raised, one plan at a time on phones.
- Pro
Annual Savings Pricing
Billing switchesThree plans that show what yearly billing saves: each plan's head holds two bars, twelve monthly payments against one yearly payment, with the saving printed in the gap, under a monthly and yearly switch.
- Pro
Free vs Pro Pricing
Single planOne card with a big Free and Pro switch: flipping it rolls the price and turns the locks on Pro's features into checks, in a single list of eight.
- Pro
Two Plans Pricing
Plan cardsA free Personal plan beside the recommended Team plan as two cards in cards, with the monthly and annual switch in the header row and Team's price rolling to its annual amount.
- Pro
Comparison Table Pricing
Comparison tablesFour plans compared feature by feature in one table whose hairlines meet the page rails, with a billing switch, a tinted popular column and, on a phone, a plan switch that keeps the feature column beside one plan.
- Pro
Accordion Plans Pricing
Plan rowsThree plan rows for an email API, each its own band with its price and call to action in view, opening in place to list its features, with a monthly and annual switch in the header row.