Spend card Pro
One payment, every Pro piece. $10 tomorrow.
Install
npx shadcn@latest add @mu-pro/spend-cardPro. Installs with your licence key through the @mu-pro registry; the key comes with Pro. Lands in components/mu/spend-card/ with the shared foundation.
Usage
import { SpendCard } from "@/components/mu/spend-card/SpendCard";
<SpendCard
className="w-full max-w-[360px]"
days={[164.07, 347.37, 303.25 /* … one number a day, up to today */]}
plan={9000}
month="2026-11"
currency="USD"
locale="en-GB"
labels={{ title: "Compute spend" }}
/>Use with an agent Beta
npx shadcn@latest add @mu-pro/uisdk/spend-cardOptional. 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
- Arrival: once half in view, the card rises out of a small blur, the lamps warm up from the 1st to today, today's lamp flares once, and the figure rolls up from zeros. Scrolled away, every run finishes at once: off screen it draws nothing.
- Pointer / touch: press anywhere on the field and the bead glides to that day; drag to read any day. The figure rolls to that day's total (digits roll up when it grows, down when it shrinks, with a touch of motion blur on a fast roll; only changed digits move), the line reads the day, and a pill says how far over or under plan it was. Past today it reads what is left per day. Let go and it glides back to today. A sideways drag reads; up and down still scrolls the page.
- Keyboard: the field is a native range input (
aria-valuetextlike "14 Nov: $5,038.30, $838 over plan"). Arrows move a day, Page Up and Down a week, Home the 1st, End the month's end; Escape, or leaving the field, glides back to today. The focus ring sits on the bead. - Reduced motion: the card and its lamps are there at once (no rise, no warm-up, no flare), and the digits swap without rolling. Dragging still reads every day under the finger and snaps back to today on release.
- Performance: a drag rolls the figure at most every other frame, the newest day winning, and the day you let go on always lands. Before that cut a scrub cost about 72 ms a second of main thread at a 4× slowed CPU, over the library's 60 ms budget; it has not been measured again since.
Props
| Prop | Default | What it does |
|---|---|---|
days | — | numbers ≥ 0 | spend per day from the 1st; entries after today are read as the forecast (missing ones are the last week's average) |
plan | — | a number, or one number a day | the month's plan: a total spread evenly, or each day's own plan |
month | — | "YYYY-MM" or a Date | the month: its length and the day names. A Date is read in the zone where it renders; for server rendering pass "YYYY-MM", so the server and the browser agree |
today | the last entry of days | 0 to the month's length − 1 | today, as an index into days |
currency | "USD" | an ISO 4217 code | shown with its narrow symbol ($, €, £) |
locale | "en-US" | a BCP 47 tag | numbers and dates, through Intl.NumberFormat and Intl.DateTimeFormat |
labels | English | Partial<SpendCardLabels> | every word: title, pace, plan, over, under, spent, left, overBudget, overPlan, underPlan, by, scrub, value, valueAhead, empty. Templates take {amount}, {date}, {plan}, {perDay}; *…* marks the words in the over or under ink |
day | — | an index into days, or null | the day being read, controlled: change it and the bead glides there and stays (a table row's hover, a selected invoice); null returns it to today |
defaultDay | null | an index, or null | the day it starts on, when day is left out |
onDayChange | — | (day) => void | the day a person reads, as an index into days, as a drag crosses it, a key steps to it or the field is let go (null: back on today) |
loading | false | — | the month is on its way: the same card with its lamps unlit, the figure at zero, no line under it, nothing to read (the scrubber keeps a keyboard user's focus, aria-disabled), and aria-busy on the root. When it turns false the lamps warm up and the figure rolls in, as on first sight |
sound | off | true or 0–1 | a soft tick on each day a person steps through (see Sound) |
className | — | — | added to the root |
Sound
Off unless you pass sound (true, or a volume 0–1). Each day a person steps through, by dragging or with the keys, ticks softly (the library's key voice at 40%, a touch higher going forward and lower going back), at most once every 45ms so a fast drag never buzzes. The glide back to today and the arrival are silent; nothing plays on hover, on mount or from a prop change. 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.
Spend against plan, as a field of lamps. Each day of the month is a small lamp that burns at the colour of its pace: cool under plan, white on plan, amber over it, hot past twice. Drag across the month to read any day and the figure rolls to match; let go and it glides back to today.
For usage, spend and budget dashboardsMore in Usage & billing