Components / Feedback and display
ProgressBar
Shows how far a task has got: an upload, an export, the steps of a setup. When the amount is unknown it shows a moving segment instead.
When to useLink to "When to use"
- A task with a measurable amount (bytes, files, steps) that takes long enough to watch.
- A task in progress whose length is unknown, shown in place of the result:
indeterminate.
Use something else when:
- the wait is short and inside a button: the Button's
loadingstate - a small inline busy indicator is enough: LoadingDots
- the person sets the value: a Slider
UsageLink to "Usage"
import { ProgressBar } from "@arshad-shah/cynosure";
<ProgressBar label="Uploading 3 files" value={uploaded} max={total} showValue />
<ProgressBar label="Preparing export" indeterminate />Leave value out (or pass indeterminate) while the amount is unknown, then pass it once you know it. Values outside 0…max are clamped.
Value textLink to "Value text"
By default the value reads as a percentage. Pass labels.value to describe it in your own words; the same text is shown with showValue and read by screen readers.
A slim bar in a rowLink to "A slim bar in a row"
With labelHidden and no showValue, the bar is only its track: no label row, as tall as size makes it, and still named by label. Put it in a row of text (a query plan's cost, a quota beside its number) and give it the space with style={{ flex: 1 }}; it fills from the reading start in right-to-left text too.
<Inline gap="2" align="center">
<Text size="sm">Seq Scan</Text>
<ProgressBar label="Cost 1234.5" labelHidden value={45} size="sm" tone="warning" style={{ flex: 1 }} />
<Text size="sm" tone="muted">cost: 1234.5</Text>
</Inline>PropsLink to "Props"
| Prop | What it does | Type | Default |
|---|---|---|---|
labelRequired | Accessible name, shown above the bar unless labelHidden. | string | |
labelHidden | Visually hide the label (it still names the bar). | boolean | |
value | Current value between 0 and max. Leave it out (or pass indeterminate) when progress is unknown. | number | |
max | The value that means complete. Default 100. | number | 100 |
indeterminate | Progress is happening but its amount is unknown. | boolean | |
showValue | Show the value text at the end of the label row. | boolean | |
segments | Parts drawn end to end instead of one fill, from offset: a request's timing (DNS, connect, wait, download) or a waterfall row. Each has a label (read out) and a tone or category color. | ProgressSegment[] | |
offset | Where the first segment starts, in the same units as max. Default 0. | number | 0 |
marker | A thin mark across the track at this value (a target, a second position). | number | |
markerLabel | Read with the value when there is a marker. Default "marker at 75%". | string | "marker at 75%" |
tone | Colour of the fill. Default "accent". | "accent" | "neutral" | "danger" | "success" | "warning" | "info" | "accent" |
size | Bar thickness. xs is a hairline track with smaller label text, for dense desktop chrome. Default "md". | DenseSize | "md" |
labels | Replace the built-in English text: the value text. | Partial<ProgressBarLabels> | |
className | Added to the root element, for layout. | string | |
style | Layout only. Restyle through --cy-progress-bar-* tokens. | CSSProperties |
Generated from the type definitions in @arshad-shah/cynosure 0.5.0.
Behaviour and accessibilityLink to "Behaviour and accessibility"
- Role:
role="progressbar", named bylabel, witharia-valuemin,aria-valuemax,aria-valuenowandaria-valuetext. Indeterminate bars have no current value and arearia-busy. - Announcements: a progress bar is not a live region. To announce completion, say so in the page (a Notice or a Toast).
- Contrast: the fill keeps at least 3:1 against its track in every tone, in light and dark modes.
- Direction: fills from the inline start, so from the right in right-to-left text.
- Motion: the fill eases between values; the indeterminate segment sweeps, and stands still in the middle under reduced motion.
ThemingLink to "Theming"
size sets the thickness: xs 2, sm 4, md 8 and lg 12 px. xs also sets smaller label and value text and a tighter gap, for dense desktop chrome.
Tokens: --cy-progress-bar-height-{xs,sm,md,lg}, --cy-progress-bar-radius and --cy-progress-bar-track.
createTheme({ components: { progressBar: { heightMd: "6px", radius: "2px" } } });RelatedLink to "Related"
LoadingDots · Toast · Notice
These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.