Pricing toggle
Monthly or yearly: the thumb slides with a little give, and every price on the page rolls to its new amount.
Used forPricing pagesIn-app upgrade screensExtra periodsCheckout and upgrade dialogs
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/pricing-toggle. Set it up
Templates
Need the whole page?
63 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
Pricing pages
A Monthly and Yearly switch that drives every plan on the page.
In-app upgrade screens
Let people compare billing periods when they change plan.
Extra periods
Add Quarterly or Lifetime beside Monthly and Yearly.
Checkout and upgrade dialogs
A billing choice that updates the total beside it.
What it handles for you
The billing switch is the one control every pricing page has, and usually the dullest. This one also rolls every price on the page to its new amount.
A thumb with a little give
It slides and resizes to the chosen option, and the labels trade colour.
A badge that lights up
“Save 20%” sits inside Yearly and fills with your brand colour when Yearly is chosen.
Every price rolls
Each Price on the page rolls digit by digit to its new amount.
A billing note that follows
The line under the price, such as “$276 billed yearly”, slides in from the direction you switched.
Any number of periods
Pass your own options, for example add Lifetime.
A real radio group
Arrow keys move between periods. Prices are real text for screen readers.
Overview
The billing switch is the one control every pricing page has, and usually the dullest. Here the thumb slides and resizes to the chosen option with a little give at the end, and the labels trade colour. "Save 20%" sits inside Yearly and lights up in your brand colour when it’s chosen. Every Price on the page rolls digit by digit to its new amount, and the billing line underneath slides in from the direction you switched.
States
- monthly
- The thumb sits on Monthly; Yearly shows its badge in a soft tint as an incentive.
- yearly
- The thumb slides and widens over Yearly and its badge, and the badge fills with your brand colour.
- prices
- Each Price rolls to the new amount; the note ("$276 billed yearly") slides in from the toggle’s direction.
Usage
Works with
Installs with it
Built on it
- Pricing calculatorDrag to your size and watch the price roll, the plan morph and, at the top, “Let’s talk”.
- Comparison tablePlans side by side, with a column that glides to the plan under your pointer and prices that roll.
- Pricing plansPlans that turn into their own checkout: pick one and its card becomes the order, seats and totals rolling, then Continue opens your checkout.
In a pricing section
One toggle drives every plan column; each Price rolls on its own.
Props
- value / onValueChange
- string / (value) => void
- The chosen billing period.
- options= Monthly, Yearly “Save 20%”
- { value; label; badge? }[]
- Any number of periods, e.g. add Lifetime.
- Price: amount / currency / period= — / "USD" / "/mo"
- number / string / string
- The figure that rolls, its currency, and the period after it (hidden at 0).
- Price: locales
- string | string[]
- Format the price in this locale on the server and in the browser. Without it, a server render shows en-US and switches to the visitor’s locale after hydration ("$29" can become "US$29" in en-GB).
- Price: note / direction
- string / 1 | -1
- The line under the price, sliding in from the way the toggle moved.
- Price: numberClassName
- string
- Size and weight of the figure.
Accessibility and motion
- The toggle is a real radio group: arrow keys move between periods, and only the chosen one is in the tab order.
- Prices are real text for screen readers; the rolling digits are decoration on top.
- Installs Number roll alongside it.
- Price hydrates cleanly when server-rendered: without locales it formats in en-US until hydration, then in the visitor’s locale, swapped in place. The note is your own text, so if you write amounts in it, pass the same locales to Price to keep them alike.
- With reduced motion, the thumb jumps and prices change in place.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Number roll.
Source
Registry item: /r/pricing-toggle.json


