Plan Switcher
ProNewChange plan in place: a monthly or yearly switch that says what yearly saves, plans as radio cards with the current one marked, and a sentence that states the change before it is confirmed.
Installation
pnpm dlx shadcn@latest add @viewport/plan-switcher
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| plans* | Plan[] | — |
| current* | stringThe id of the plan the account is on now. | — |
| value* | stringThe id of the plan selected. | — |
| onValueChange* | (id: string) => void | — |
| interval* | "monthly" | "yearly" | — |
| onIntervalChange* | (interval: "monthly" | "yearly") => void | — |
| unit | stringWhat a price is per, e.g. "seat". | — |
| format | (amount: number) => string | dollars |
| className | string | — |
Accessibility
- Two radio groups: the billing interval and the plan.
- The current plan is labelled in text.
- The effect of the change is written out and announced.
- Prices use tabular numerals, so they do not shift when the interval changes.