Billing Slider
A range slider for how many hours a package bills, with a floor, marks, evidence along the track and a striped gap.
BillingSlider sets how many hours a by-estimate package bills. The track starts at the floor (the signed low), carries the package's high as a mark, and ends at a maximum the caller computes (as far as the ceiling allows). What was worked sits on the track as evidence, so the operator can see how far the bill is from it. hue reads Paper's project hues, so switch the site theme to Paper (light or dark) to see the colours as designed. On other themes the slider falls back to neutrals.
The slider
Drag it anywhere on the track, or use the keys. The filled range runs from the floor to the thumb. The notch is the high: a mark, not a stop. Past it the range turns to stripes. Along the track's foot, the solid strip and tick are the worked hours; counted agent hours extend them dotted (switch them off below and the tick moves back); proposed hours extend them pale, with a dashed tick. The striped emerald gap between the thumb and the tick is money at stake: undecided, and worked past what it bills.
Keys
| Key | Does |
|---|---|
| ← → (or ↓ ↑) | One step (a quarter hour) |
| Shift + arrows, Page Up Page Down | Four steps (an hour) |
| Home | The floor |
| End | The end |
| Enter | Calls onValueCommit |
| Esc | Goes back to savedValue |
Arrow keys only move the thumb. Saving happens on Enter or when a drag ends, so stepping through values never saves each one.
States
Each row is live: drag it, or focus it and use the keys. Enter saves after a short wait. The failed row snaps back to its saved value, which is the caller's job: on status="failed", put value back to savedValue.
Colour
hue takes a Paper project-hue angle (75, 99, 123 … 339) and sets two variables on the slider: --billing-slider-hue-fill-strong (the filled range) and --billing-slider-hue-ink (the thumb ring, the evidence, the ticks and the stripes past the high). For a colour that is not a Paper hue, leave hue off and set them yourself.
A theme binds the rest through the billing-slider component tokens: track-bg, thumb-bg, thumb-grip and gap-color. Paper draws the gap in Emerald, the money-at-stake colour, never coral. Every part carries a data-slot (billing-slider-track, -fill, -past, -gap, -evidence, -agent, -proposed, -mark, -tick, -thumb, -labels) for anything else.
Installation
npx visor add billing-sliderThis copies two files into your project:
components/ui/billing-slider/billing-slider.tsx— the componentcomponents/ui/billing-slider/billing-slider.module.css— the styles
API Reference
BillingSliderProps
| Prop | Type | Default | Description |
|---|---|---|---|
value* | number | — | What it bills. Controlled. |
onValueChange* | (value: number) => void | — | Called while dragging and on every key step. |
onValueCommit | (value: number) => void | — | Enter, or releasing the thumb after a drag. Arrow keys never commit. |
savedValue | number | — | The last saved value. Escape returns the thumb here. |
min* | number | — | The floor. Nothing below it. |
max* | number | — | The track's end, computed by the caller (as far as the ceiling allows). |
step | number | 0.25 | The arrow step. Shift + arrows step four times it (an hour). |
marks | { value: number; label?: ReactNode; hatchPast?: boolean }[] | [] | Notches across the track. A mark is not a stop. `label` writes text before its value in the labels row; past the mark with `hatchPast` the filled range stripes. |
evidence | { value: number; agent?: number; proposed?: number } | — | Worked hours: a solid strip along the foot and a tick at its end. `agent` extends it dotted and moves the tick (leave it off when agent time does not count); `proposed` extends it pale with a dashed tick. A tick past `max` becomes an arrow at the end. |
gap | boolean | false | Stripe the gap between the thumb and the evidence tick, in `--billing-slider-gap-color` (Emerald on Paper, money at stake). |
hue | number | — | A Paper project-hue angle (75 to 339). Reads `--paper-hue-<angle>-fill-strong` (the fill) and `-ink` (the thumb ring, evidence, ticks and stripes). |
size | "md" | "lg" | "md" | `md` is the 40px row track; `lg` is the 56px hero track. |
status | "saving" | "failed" | — | `saving` pulses the thumb. On `failed`, put `value` back to `savedValue`. |
disabled | boolean | false | Turns off the pointer and the keys and dims the thumb ring. |
formatValue | (value: number) => string | String | Formats a value for the bubble and the labels row. |
valueText | (value: number) => string | — | `aria-valuetext`: the formatted value and its amount. Defaults to `formatValue`. |
minLabel | ReactNode | — | Text before the floor's value ("Low"). |
maxLabel | ReactNode | — | Text before the end's value ("Ceiling allows"). |
BillingSlider renders a <div> and accepts all standard div attributes. aria-label and aria-labelledby go to the thumb.
Accessibility
- The thumb has
role="slider"witharia-valuemin(the floor),aria-valuemax(the end) andaria-valuenow. PassvalueTextsoaria-valuetextreads the value and its amount ("Bills 9.5 h, $1,140"). - Name it with
aria-labeloraria-labelledby; both land on the thumb. - Marks, evidence, ticks and stripes are decoration on the track. Say what they mean in text next to the slider (a legend, or the message under it).
- Past the high and in the gap, stripes carry a pattern as well as a colour (WCAG 1.4.1).
- The labels row and the bubble are 13px on Paper, in the secondary and primary text colours, which meet AA on the page and card surfaces in light and dark.
- Saving pulses the thumb's ring; with reduced motion the pulse is off.