Signature
Billing toggle
Monthly ↔ yearly with rolling prices.
Monthly or yearly
A two-option segmented control with a savings badge on the yearly option. Switch it and the price rolls digit by digit to its new value while the highlight glides across.
Billed monthly, cancel anytime
When to use
- Pricing pages and upgrade dialogs where the same plans are sold monthly and yearly.
- Any price that changes with a choice the user just made: seats, region, billing period.
Not for: more than two periods (use a SegmentedControl with your own items), or a setting that takes effect immediately on an account (use a switch with a confirmation).
Pricing table
One toggle drives every card. Each BillingPrice sets announce={false} so screen readers don’t hear three prices at once; the selected option is announced by the toggle itself.
Starter
For freelancers and side projects.
Team
For teams that ship every week.
Business
SSO, audit log and priority support.
Labels, currency and locale
Labels and the badge are any content. Prices are formatted with Intl.NumberFormat, so currency symbols, separators and decimals follow the locale. Whole amounts show no decimals; anything else shows two.
API
BillingToggle
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue | 'monthly' | 'yearly' | — / 'monthly' | Controlled or initial billing cycle. |
| onValueChange | (value: BillingCycle) => void | — | Called when the cycle changes. |
| savings | ReactNode | — | Badge in the yearly option, e.g. “Save 20%”. Part of its accessible name. |
| monthlyLabel / yearlyLabel | ReactNode | 'Monthly' / 'Yearly' | Option labels. |
| size | 'sm' | 'md' | 'lg' | 'md' | Height: 32 / 38 / 46px (taller on touch screens). |
| fullWidth | boolean | false | Stretch to the container. |
| name | string | — | Submits the cycle with a form. |
| aria-label | string | 'Billing period' | Accessible name of the radio group. |
BillingPrice
| Prop | Type | Default | Description |
|---|---|---|---|
| amount | number | — | The price. Changing it rolls the digits. |
| currency | string | 'USD' | ISO 4217 code. |
| locale | string | 'en-US' | Fixed by default so server and client render the same. |
| format | Intl.NumberFormatOptions | — | Merged over the currency defaults. |
| period | ReactNode | — | Muted text after the amount, e.g. “/ month”. |
| size | 'sm' | 'md' | 'lg' | 'md' | Amount size: 24 / 34 / 40px. |
| announce | boolean | true | Polite live region for the new price. |
Need the rolling digits alone? BillingPrice is built on AnimatedNumber from the animated counter.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus to the selected option (one tab stop). |
| ← → ↑ ↓ | Moves to the other option and selects it. |
| Home / End | Selects Monthly / Yearly. |
Accessibility
- A radiogroup named “Billing period” with two radios; the savings badge is read with the yearly option (“Yearly Save 20%”).
- BillingPrice exposes one plain text node (“$24”) inside a polite, atomic live region; the rolling cells are hidden from assistive tech.
- The badge uses the success tint with the success text colour, measured at 4.5:1 or more in light and dark.
Motion
- The highlight pill glides on the morph spring; it does not animate on first render.
- Each changed digit rolls on the morph spring; digits that appear (9 → 10) rise in.
- Pressing the yearly option nudges the badge to .96 on the snappy spring.
- Reduced motion: the selection and the price change instantly.