A live calculator: declarative inputs (number, slider, select, toggle, option cards, add-on checkboxes) feed a pure formula you pass, and a summary panel shows the total or a range, line items, a spec sheet, notes and a call to action that hands the selection on. Fee estimates, quotes, package builders, usage pricing and planners. Sticky beside the inputs on wide containers, a bottom bar on narrow ones.
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { Estimator } from "@vamos-ui/react";
<Estimator
inputs={[
{ type: "options", id: "size", label: "Home size", variant: "segmented", options: [{ value: "s", label: "Studio" }, { value: "m", label: "2 rooms" }] },
{ type: "slider", id: "km", label: "Distance", min: 1, max: 80, format: (v) => `${v} km` },
{ type: "addons", id: "extras", label: "Extras", options: [{ value: "pack", label: "Packing", meta: "+ $900" }] },
]}
formula={(v) => {
const total = base[v.size as string] + (v.km as number) * 18;
return { total, range: [total * 0.9, total * 1.1], lines: [{ id: "base", label: "Crew and truck", amount: total }] };
}}
cta="Get a fixed price"
onSubmit={(values, result) => openQuoteForm(values, result)}
/>The figure is announced once per change through a polite live region ("Total: $8,200"); line items stay in a description list.
Inputs are kit controls — RadioGroup, Checkbox cards, Slider, Switch, NumberInput, NativeSelect — so keyboard behaviour and labels come with them.
Keep the formula the single source of prices: use the same function for the "from" prices on the page and on the server that confirms the quote.
Examples
Fee statement into a form
numbered inputs, an add-on shown only for one company type (when), subtotal and tax lines, and name + form posting the selection as JSON with a contact form elsewhere on the page.
$90 per person a month: payslips and filings.
Usage pricing across plans
Lines compare plans; the cheapest that fits is highlighted with a badge, plans that do not fit show text instead of an amount.
Viewers are free on every plan.
Planner with extra content
A select and two sliders drive a projection; facts carry the goal and the month it is reached, summaryExtra adds a progress bar (or a chart).
API
Estimator
| Prop | Type | Default |
|---|---|---|
inputsEach { type, id, label, hint?, when?, disabled? } plus per type — "number": min/max/step · "slider": min, max, step?, marks?, format?, withInput? · "select": options (string labels) · "toggle": description? · "options": options, variant "card" | "segmented", columns? · "addons": options, columns?. Options are { value, label, description?, meta?, icon?, disabled?, when? }. | EstimatorInput[] | — |
formulaPure. Returns { total: number | null, range?: [low, high], lines?, facts?, notes?, ready? }. Lines are { id, label, amount?, text?, detail?, kind?: "item" | "discount" | "subtotal" | "tax" | "info", highlight?, badge? }. | (values) => EstimateResult | — |
values / defaultValues / onValuesChangeRecord<id, number | string | boolean | string[]>. onValuesChange gets (values, result). | EstimatorValues | — |
formatHow amounts read; currency uses the provider currency or `currency`. | "currency" | "number" | (n) => string | "currency" |
currency / fractionDigitsCurrency code and fraction digits. | string / number | provider / 0 |
title / totalLabel / totalSuffixPanel heading, label beside the figure ("Monthly, excl. tax") and text after it ("/ month"). | ReactNode | — |
numbered01, 02… before each input label. | boolean | false |
cta / ctaHref / onSubmitThe call to action. Disabled while the result is not ready (total null or ready: false). | ReactNode / string / (values, result) => void | — |
name / form / serializeA hidden field with the selection (default JSON of { values, total, range }); form ties it to a form elsewhere. | string / string / (values, result) => string | — |
summaryExtraExtra content in the panel: a chart, a timeline. | (values, result) => ReactNode | — |
stickyTopSticky offset below a fixed header. | string | "1.5rem" |
labelsDictionary namespace "estimator": summary, total, range, live, empty, details, step. | Partial<EstimatorLabels> | — |
estimatorDefaults(inputs, overrides?) · effectiveEstimatorValues(inputs, values)
| Prop | Type | Default |
|---|---|---|
returnsInitial values, and the values the formula sees (hidden add-ons dropped). Use them to run the formula on the server or in tests. | EstimatorValues | — |