Skip to content
Hazine

Usage Slider Calculator

Pro

One slider on a stepped, non-linear volume scale that maps to a plan, a monthly price and the rate per thousand units, with a sales prompt at the last stop. Use for one-metric usage pricing.

How it differs. A single continuous control on a ruler of unevenly sized stops drives everything: the plan, the price, the unit rate and its change against the entry rate are all read off one thumb position.

Install

pnpm dlx shadcn@latest add @hazine/pricing-calculator-usage-slider

Adds 1 file, 2 shadcn primitives (button, label), 2 Hazine items (@hazine/heading, @hazine/use-controllable-state), and 1 package (lucide-react).

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": {
      "url": "https://api.hazine.dev/r/{name}.json",
      "headers": { "Authorization": "Bearer ${HAZINE_TOKEN}" }
    }
  }
}

Set HAZINE_TOKEN in your environment. The token comes with a Pro licence.

Props13

title
string = "Price by monthly events"
headingLevel
HeadingLevel = 2
stops
UsageStop[] = DEFAULT_STOPS
value
number
Monthly volume in units. A volume between two stops selects the stop that covers it.
defaultValue
number = 1_000_000
onValueChange
(units: number) => void
unit
string = "events"
Plural noun for what is metered, lower case.
currency
string = "USD"
locale
string = "en-US"
signupHref
string = "/signup"
salesHref
string = "/contact-sales"
disabled
boolean = false
note
string = DEFAULT_NOTE
Hint under the scale. Say here why the slider is locked when it is disabled.

Also accepts every prop of Omit< React.ComponentProps<"section">, "title" | "defaultValue" >.

Accessibility

Pattern
Slider (APG, opens in a new tab), Pricing structure, Landmarks and headings
Keyboard
Keyboard support for Usage Slider Calculator
KeyEffect
TabMoves to the slider, then to the plan action
Arrow Right, Arrow UpMoves to the next stop on the scale. The directions swap in right to left layouts
Arrow Left, Arrow DownMoves to the previous stop on the scale
Page Up, Page DownMoves one stop up or down. On a scale of more than 11 stops the browser moves about a tenth of the scale
Home, EndJumps to the smallest volume or to the last stop, where the price becomes a sales prompt
Enter on the actionFollows the sign up link, or the sales link at a stop priced by contract
Screen reader

Section labelled by its heading. The control is a native range input with a visible label, a hint wired by aria-describedby and aria-valuetext that speaks the volume in words. The plan, price and rate sit in one atomic status region.

  • Announces: Plan {n} of {count}. {plan}. {price} per month. {units} {unit} a month, {rate} per 1K {unit}.
  • Announces: Plan {n} of {count}. {plan}. {price} per month. {units} {unit} a month at no cost.
  • Announces: Plan {n} of {count}. {plan}. Custom. {units} {unit} or more a month, priced by contract.
Reduced motion
No motion. Colour transitions only.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies5

  • button
  • label
  • @hazine/heading
  • @hazine/use-controllable-state
  • lucide-react

Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.

Tokens shipped0

None. The item is styled by the tokens your theme already has.

More in Pricing