CapBar
moleculesA usage bar with a draggable cap: value is what is used, cap is the limit you drag or arrow-key, with warn tones, an expected marker, uncapped mode, stacked layout and readonly.
Provider caps
one row per provider: value, bind:cap, hint, an expected marker and onchange when the drag or arrow keys settle.
Size, layout and stacking
size="lg", layout="stacked" puts the label above the bar, stackBelow stacks only under that container width, labelWidth and readoutWidth align columns.
States
readonly over its cap, uncapped (cap={null}, clearAtMax, uncappedLabel), the caption snippet, custom step and min/max, and the 0% / 100% edges.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | 0 | Consumption, in percent of `max`. |
cap bindable | number | null | 100 | Cap position; bindable, moved by drag/keyboard. `null` is uncapped. |
min | number | 0 | |
max | number | 100 | |
step | number | 5 | Snap increment for drag and keyboard. |
warnAt | number | 75 | Consumption at which the fill turns `--warn`. |
size | 'md' | 'lg' | 'md' | |
layout | 'row' | 'stacked' | 'row' | `'stacked'` puts label + readout on a line above a full-width track. |
stackBelow | string | — | Own-width threshold (px/em/rem) below which `layout` becomes `'stacked'`. |
marker | number | null | — | Reference position on the track, in the same units as `value`. |
markerLabel | string | — | |
markerTone | 'neutral' | 'ok' | 'warn' | 'danger' | 'neutral' | |
uncappedLabel | string | 'no cap' | Spoken and readout text for `cap === null`. |
clearAtMax | boolean | false | Moving the cap to `max` yields `null` instead of `max`. |
capLabel | string | — | Accessible name of the cap handle. Defaults to `${label} cap`. |
capValueText | string | ((cap: number | null) => string) | — | Spoken value of the cap handle. Defaults to `cap ${cap}%`. |
label | string | Snippet | — | |
labelWidth | string | '96px' | |
readout | string | Snippet | — | Overrides the default `{value}% · {hint}` readout. |
readoutWidth | string | 'auto' | |
hint | string | — | |
caption | Snippet | — | |
tooltip | string | — | Track tooltip; defaults to "cap N% — drag the bar". |
readonly | boolean | false | |
oninput | (cap: number | null) => void | — | Fires live while dragging or stepping. |
onchange | (cap: number | null) => void | — | Fires once the cap is committed (pointer release / key-up). |
class | string | '' | |
style | string | '' |