BillingToggle

Monthly/yearly switch. The thumb stretches to the choice and a savings badge pops in on yearly. Pricing.

Open playground

About

BillingToggle is a React component in the Pricing category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { BillingToggle } from "@ashutoshswamy/smoui" and set value, onChange, saveLabel.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { BillingToggle } from "@ashutoshswamy/smoui";

<BillingToggle saveLabel="Save 20%" onChange={(b) => setBilling(b)} />

Props 3

value / defaultValue

Controlled or initial value.

"monthly""yearly"default "monthly"
onChange

Called on change. Arrow keys switch.

(value: Billing) => void
saveLabel

Badge shown beside Yearly. Empty hides it.

stringdefault "Save 20%"