Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Plan Switcher

ProNew

Change 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

PropTypeDefault
plans*Plan[]—
current*string

The id of the plan the account is on now.

—
value*string

The id of the plan selected.

—
onValueChange*(id: string) => void—
interval*"monthly" | "yearly"—
onIntervalChange*(interval: "monthly" | "yearly") => void—
unitstring

What a price is per, e.g. "seat".

—
format(amount: number) => stringdollars
classNamestring—

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.