ProgressBar
A thin bar with a filled share, for progress toward a total.
Overview
How far something has got toward a whole: money saved, steps done.
Progress
Do
Kitchen fundedR 45 000 of R 75 000
import { Body, Caption, Cluster, ProgressBar, Stack } from "@hackcove/ui";
<Stack gap="xs">
<Cluster justify="between">
<Body>Kitchen funded</Body>
<Caption>R 45 000 of R 75 000</Caption>
</Cluster>
<ProgressBar value={45000} max={75000} label="Kitchen funded" />
</Stack>Don't
import { ProgressBar } from "@hackcove/ui";
<ProgressBar value={60} label="Kitchen funded" />
Scale
Do
import { ProgressBar } from "@hackcove/ui";
<ProgressBar value={3} max={12} label="Months saved" />
value is on the scale of max (100 unless you pass one): three of twelve is value={3} max={12}.Don't
import { ProgressBar } from "@hackcove/ui";
<ProgressBar value={0.25} label="Months saved" />
0.25 is read as a quarter of one percent, not a quarter of the bar.Usage
valueis on the scale ofmax, which is 100 unless you pass one: three of twelve isvalue={3} max={12}. A fraction such as0.25is read as a quarter of one percent. A value pastmaxis held at full.labelis required and names what the bar measures.- Say the figures in words beside the bar; the bar draws none.
toneisaccent,positive,warnornegative;sizeissm(default),mdorlg.- A share between two parties is a
SplitBar; the parts of one whole are aStackedBar.
Accessibility
- A ProgressBar has
role="progressbar",aria-labelset tolabel, andaria-valuemin,aria-valuemaxandaria-valuenowon a 0 to 100 scale. - The announced percent is whole, and is never 0 or 100 unless the value truly is.
- The bar draws no text, so the words beside it carry the figures for everyone.
API
ProgressBar
A thin horizontal bar with a filled share, for progress toward a total. value is held to 0–max. label names what it measures, for a screen reader, which also hears the percentage.
label required- Type
string
maxDefaults to 100.
- Type
number- Default
100
sizeDefaults to "sm".
- Type
"sm" | "md" | "lg"- Default
sm
toneDefaults to "accent".
- Type
"positive" | "warn" | "accent" | "negative"- Default
accent
value required- Type
number