Switch
Billing Switch
NewThe Monthly / Yearly switch for pricing pages, as a segmented pill or two labels around a switch, with a savings badge.
npx motionsnack add billing-switchCustomize
<BillingSwitch />Props
12 properties
| Property | Type | Default | Description |
|---|---|---|---|
| value | 'monthly' | 'yearly' | - | Controlled period. |
| defaultValue | 'monthly' | 'yearly' | 'yearly' | Period on first render when uncontrolled. |
| onChange | (value: 'monthly' | 'yearly') => void | - | Called with the new period. |
| name | string | - | Name submitted with a form. |
| variant | 'segmented' | 'switch' | 'segmented' | Deprecated: 'switch' renders the same segmented control. |
| size | 'sm' | 'md' | 'md' | Deprecated: segmented controls are 48 only; both values render 48. |
| className | string | '' | Extra classes on the wrapper. |
| monthlyLabel | string | 'Monthly' | Text of the monthly option. |
| yearlyLabel | string | 'Yearly' | Text of the yearly option. |
| badge | string | 'Save 20%' | Small badge next to the yearly option. Empty hides it. |
| ariaLabel | string | 'Billing period' | Name of the control for screen readers. |
| disabled | boolean | false | Disables the control. |
About Billing Switch
Billing Switch is the small control every pricing page needs. As a segmented pill, a black or white thumb slides between Monthly and Yearly and inverts the chosen label; as a switch, the two words sit on either side of the library's switch and either word can be clicked. A small outlined badge such as Save 20% sits next to the yearly option and pops up to full strength when yearly is chosen, waiting dimmed otherwise. The pill is built on two native radios and the switch on a checkbox with the switch role, so keyboard, forms and screen readers work as expected, and keyboard focus shows the library's soft outline. Labels and the badge are props, in two sizes.
What's included
- Segmented pill with a sliding thumb
- Or two labels around a switch
- Savings badge that pops in for yearly
- Native radios or a switch underneath
- Clickable labels and keyboard support
- Two sizes, every text as a prop
- Light and dark look
- Type
- Animated React switch component
- Library
- Components · Switch
- Stack
- Next.js, React, Tailwind CSS
- Added
- 2026-11-23
- Install
npx motionsnack add billing-switch