shadcn.io is not affiliated with official shadcn/ui
Compact Segmented Tab Control CTA Block for React
A slim upgrade band between solid rails, split by a divider: the headline with a rolling price at the start, a billing segment and a Shine Button on the end.
Installation
Overview
Nudge visitors to upgrade without a full pricing table with this compact segmented control banner. One band between the page's solid rails, split by a divider that meets the top rule, holds a headline with the current price at the start and, on the end side, a three-way Segment Group for Monthly, Quarterly and Yearly beside a Shine Button. Choosing a period rolls the price to its new amount with Sliding Number and rewrites the line beside it: what each payment costs, how often it comes and how much it saves against monthly billing, all worked out from the prices. On phones the two cells stack under a rule, and the segment and the button fill the width. Built with Segment Group, Sliding Number, Shine Button, Guides and Tailwind CSS, with CSS transitions only. For in-page upgrade nudges, a strip above the footer and secondary plan choices between sections.
FAQ
How do I change the plans and prices?
Edit the PLANS array at the top of the file. Each plan has its label, its price per month, the months each payment covers and the value that identifies it. The first plan is the list price: every saving compares the others with it. The "Billed" line, the payment amount and the saving are computed from those numbers, and the saving is rounded down so the bar never promises more than the price delivers. Add a fourth plan by adding an entry: the segment and the line grow with the data.
How do I send the chosen plan to checkout?
The Upgrade button is a real link, so point its href at your checkout and add the plan to it, for example /checkout?plan=pro&billing=quarterly; the chosen plan's value is what you want. It's a ShineButton with render set to an a element and nativeButton={false}. The link's accessible name carries the plan, as in "Upgrade, billed quarterly".
Is it accessible?
Yes. The segment is a radio group named "Billing period": Tab reaches the chosen period and the arrow keys move and choose. The price rolls visually, but its value stays in text for screen readers, and one polite live region says the new plan after a change, for example "Quarterly: $15 per month. Billed $45 every 3 months, 21% less than monthly." Nothing is announced while the page loads. The headline is the block's h2.
Why doesn't the bar change size when I switch?
The price's digits are tabular, and the three "Billed…" lines share one grid cell: the longest sets its width and height, and the two that aren't chosen are hidden from sight and from screen readers. Switching only changes which one shows.
How does it fit a phone?
Below the md breakpoint the band stacks: the headline and price, a rule, then the segment across the full width and the button across the full width. From md it's one row split by the divider, with the headline taking the space left over, so it holds its shape down to a 320 px screen.
Related
- Pro
Centered Light Tier Selector CTA
Pickers and togglesA centred sponsorship call to action for an open-source project: a band of five amount cells on shared hairlines, a Shine Button that names the chosen monthly amount, a Custom cell that opens a number field in the same space, and a closing band that counts the sponsors.
- Pro
Split Panel Pill Toggle Plan Card CTA
Prices and offersA split call to action for a product analytics tool: the pitch, a payment-method pill and the Shine Button at the start, one plan card in a hairline frame at the end, between solid rails.
- Pro
Split Panel Tier Benefits CTA
Pickers and togglesA reverse split call to action for a partner program: a referral dial in a hairline frame at the start, beside the tiers as ruled rows and a Shine Button that names your tier.
- Pro
Split Panel Dual Preview CTA
Product previewsA reverse split CTA for an A/B testing tool: two variants as choice cards on a tinted panel flush to the rail, each with a page preview, a click-through ring and a lift badge, beside a Shine Button that follows the choice.
- Pro
Payment Schedule Pricing
Billing switchesTuition paid once or in 3, 6 or 12 installments: four chips pick the schedule and a calendar of twelve monthly cells fills with the dated payments and their amounts, over the total and the call to action.
- %Pro
Committed Spend Discount Pricing
Billing switchesFour big commitment chips, $500 to $50k a month, and in the same row the discount each earns at display size, over every unit's committed price against its on-demand price, with the call to action beside the result.