Returns calculator Pro
One payment, every Pro piece. $10 tomorrow.
Install
npx shadcn@latest add @mu-pro/returns-calculatorPro. Installs with your licence key through the @mu-pro registry; the key comes with Pro. Lands in components/mu/returns-calculator/ with the shared foundation.
Usage
import { ReturnsCalculator } from "@/components/mu/returns-calculator/ReturnsCalculator";
<ReturnsCalculator className="w-full max-w-[360px]" onValueChange={(v) => console.log(v)} />Use with an agent Beta
npx shadcn@latest add @mu-pro/uisdk/returns-calculatorOptional. An AI agent in your app can read and set this piece by name, and you can ask before anything it can’t undo. The piece itself doesn’t change; installs with your Pro key, like the piece. Built on UI SDK 0.1.0-beta.23, which is in beta too, so this add-on follows its releases.
Source
How it works
Building with an agent? Hand it a ready prompt for this piece.
Input and reduced motion
- Pointer / touch: drag the thumb, or press anywhere on the ruler and the thumb glides there and follows; drag the big amount sideways to scrub it the same way. The amount steps under the finger; let go with speed and it lands on the step the throw carries it to. A press on the amount that doesn't travel opens it for typing. Escape mid-drag puts the amount back. Up and down still scroll the page.
- Keyboard: the thumb is a slider (
aria-valuetextlike "$500 a month"): arrows a step, Shift+arrows or Page Up and Down a tenth of the range, Home and End the ends. The amount is a text field (Enter or leaving it commits, Escape cancels). Mode and duration are radio groups (arrows move and pick). "edit" opens the rate in place. The result is read out politely once it settles. - Reduced motion: the pill, underline and thumb jump, digits swap without rolling, and there is no glint. A drag still tracks the hand and snaps on release.
Props
| Prop | Default | What it does |
|---|---|---|
value | — | ReturnsValue: { mode, amount, years, rate } | controlled value; pair it with onValueChange |
defaultValue | { mode: "monthly", amount: 500, years: 5, rate: 12 } | any part of the value | uncontrolled start |
onValueChange | — | (value) => unknown | every change a person makes: a step the hand crosses, a key, a typed amount or rate, a mode or a duration (never an echo of value). It may return a promise (a save): the root carries aria-busy until the newest one settles, "Saving…" shows after 400ms, and a rejection sets data-error and shows "Not saved" while keeping what the person set. The card never waits for it |
name | — | a string | posts with a <form>: four hidden fields, {name}.mode, {name}.amount, {name}.years, {name}.rate |
min, max, step | 0, 1500, 25 | numbers, min < max | the amount's range; the ruler and the keys snap to step (a typed amount is kept as typed, clamped) |
durations | [1, 3, 5, 10] | years | the duration options |
currency | "USD" | an ISO 4217 code | shown with its narrow symbol, no cents |
locale | "en-US" | a BCP 47 tag | numbers through Intl.NumberFormat; typed values read its decimal mark |
accent | off | boolean | the light (fill, glow, underline, lit ticks) takes --mu-signal instead of apricot |
sound | off | true or 0–1 | a soft tick as the hand crosses each step while it drags the ruler or the amount (see Sound) |
labels | English | Partial<ReturnsCalculatorLabels> | every word; templates take {n}, {span}, {rate}, {total}, {gain}, {pct}, {paid}; saving and error are the save's words |
className | — | — | added to the root |
Sound
None. It loads in silence.
Off by default. With sound (or a volume, sound={0.5}) a soft tick plays each time a drag crosses a step of the ruler or the amount, at least 60ms apart so they never stack. Never on a click, a key, the glide after you let go, or when value changes from your code. setMuted(true) from components/mu/sounds.ts silences every cottoncandy item at once.
Licence
Included with Pro: use it in unlimited end products for you and your clients; no reselling as a kit. See the licence.
Set what you put in and for how long; drag the lens ruler and the future value rolls to match.
For savings and investment calculatorsMore in Usage & billing