Billing toggle
A monthly and yearly switch with a savings badge and prices that roll to the new amount.
npx shadcn@latest add @silicon-ui/billing-toggleInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/billing-toggleManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/billing-toggle/billing-toggle.tsx
- components/silicon-ui/billing-toggle/billing-toggle.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/animated-counter/animated-counter.tsx
- components/silicon-ui/animated-counter/animated-counter.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
BillingToggle
| Prop | Type | Default |
|---|---|---|
value* | string | — |
onValueChange* | (value: string) => void | — |
options | BillingToggleOption[] | DEFAULT_OPTIONS |
labelAccessible name of the group. | string | "Billing period" |
size | "md" | "lg" | "md" |
className | string | — |
BillingPrice
| Prop | Type | Default |
|---|---|---|
amount* | number | — |
currency | string | "$" |
periodPeriod after the price, e.g. "per month". Swaps in place when it changes. | string | — |
wasPrevious price, shown struck through when it is higher than `amount`. | number | — |
decimals | number | 0 |
className | string | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokensanimated-counter