Skip to content
Sign in
MarketingUsage price calculatorMenu

Usage price calculatorPro

Sliders for what a customer will use (tokens, images, voice minutes) and what every plan would cost for it, with the cheapest plan that covers the usage marked.

ProSliders for tokens, images and voice minutes price every plan in tabular figures, with the cheapest plan that covers the usage marked.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/usage-price-calculator

Usage

tsx
import { UsagePriceCalculator } from "@/components/ui/chatcn/pro/usage-price-calculator"

<UsagePriceCalculator meters={meters} plans={plans} yearlyDiscount={0.2} onSelectPlan={startCheckout} />

A meter is { id, label, unit, min, max, defaultValue, scale?, step?, hint? }; use scale="log" for tokens, which span orders of magnitude, and the slider snaps to readable stops (1, 2, 2.5 and 5 times a power of ten). A plan is a monthly base with included usage, rates per per units beyond it, and optional limits. Prices roll in tabular figures as the sliders move. A plan the usage has outgrown says which meter is over; when even the biggest is outgrown, it points to sales.

The math is exported for your own pricing pages: quotePlan and recommendPlan from @/lib/chatcn-pro-marketing. Pass currency, locale and labels to translate every string.

Every section is full width with a 16 px gutter on phones and 32 px from 768 px, content capped at 1200 px. Layout follows the section's own width through a container query, not the viewport, so a section in a narrow column lays out like a phone.

Examples

Outgrown plans, locales and disabled

Usage past two plan limits, a single slider priced in euros on a German page, and the disabled state.

ProUsage past two plan limits, a single slider priced in euros on a German page, and the disabled state.

Props

PropTypeNotes
titleReactNodeOptional section headline, an h2
descriptionReactNodeThe paragraph beside the headline
metersUsageMeter[]Required. One slider each
plansPricePlan[]Required. Cheapest base first
usage, defaultUsage, onUsageChangeRecord<string, number>By meter id
yearlyDiscountnumber0 to 1. Shows the Monthly and Yearly switch
period, defaultPeriod, onPeriodChange"monthly" | "yearly"
currency, localeDefault USD and the page locale
onSelectPlan(planId, quote) => voidA plan's action
recommendedLabel, contactLabelstringDefault "Best fit", "Talk to sales"
labelsPartial<UsagePriceLabels>Every other string
disabledbooleanFor example while prices load
footnoteReactNodeTaxes, how overage is billed

Keyboard

KeyAction
ArrowLeft / ArrowRightMoves a slider one step (mirrored in right to left)
PageUp / PageDownMoves a slider by a large step
Home / EndMinimum and maximum
TabMoves through the period switch, the sliders and the plan actions

Accessibility

  • Each slider is a native range input labelled by its meter, with a value text such as 25M tokens and the hint as its description.
  • A polite live region says the recommendation when it changes (Best fit: Team), not on every slider step.
  • The recommended plan is marked by its ring, a check and the words, never by color alone.

Motion

  • Prices roll digit by digit as the sliders move; the thumb grows slightly while dragged.
  • Under reduced motion prices change in place and the thumb does not grow.