API: components
Progress
How far a task has gone, or an unknown amount of progress, as the ARIA progressbar, with its value formatted by Intl.NumberFormat, in each framework.
Shows how far a task has gone (the ARIA progressbar
role; the APG has no pattern of its own, its
range properties practice
applies): a value between min and max, or null for an unknown amount (indeterminate). It is
not interactive. A gauge of a known quantity (a disk's usage, a score) is a Meter, which comes
later.
Behaviour
- Value: a number, clamped to
[min, max], ornullfor an indeterminate progress. - Status:
indeterminate(null),complete(the clamped value ismax), elseprogressing; every part carries it as one ofdata-indeterminate,data-complete,data-progressing. - Format: without
format, the value is written as a percentage of the range ("40%"); withformat(Intl.NumberFormatOptions, inlocale), as it says ("128 GB"). The Value and the Root'saria-valuetextuse it;getAriaValueTextwins over it for the Root. Withoutlocale, the runtime's default: a page rendered on a server passeslocale, so the server formats as the browser does. - Indeterminate: no
aria-valuenowand noaria-valuetext(no text of its own), unlessgetAriaValueTextgives one; the Value is empty, and the Indicator has no size: its animation is your CSS, fromdata-indeterminate. - Label: names the Root (
aria-labelledby) while it is rendered; or give the Root anaria-label. - Indicator: grows from the inline start (right to left in RTL), with
--progress-indicator-sizefor a recipe that draws it otherwise (a ring).
Anatomy
| part | element | data-primitives-part | role |
|---|---|---|---|
| Root | div | progress-root | the progressbar; holds the value |
| Label | span | progress-label | names the Root |
| Value | span | progress-value | shows the formatted value |
| Track | div | progress-track | the rail |
| Indicator | div | progress-indicator | the filled part, inside the Track |
Usage
import { Progress } from "@fragiola/primitives-react/progress";
<Progress.Root value={128} max={512} format={{ style: "unit", unit: "gigabyte" }} locale="en-US">
<Progress.Label>Storage</Progress.Label>
<Progress.Value />
<Progress.Track>
<Progress.Indicator />
</Progress.Track>
</Progress.Root>;Props
Every part also takes what the primitive contract gives:
render (Vue: as and the render slot), a class and a style, a ref, and any attribute, which
it forwards. Vue binds them as props (:value, :get-aria-value-text), and Angular as inputs
([value], [getAriaValueText]).
Root
| prop | type | default | description |
|---|---|---|---|
value | number | null | required | the value, clamped to [min, max]; null for indeterminate |
min | number | 0 | the lower bound |
max | number | 100 | the upper bound |
format | Intl.NumberFormatOptions | a percentage of the range | how the Value and aria-valuetext write the value |
locale | string | the runtime's | the locale of the format (a BCP 47 tag) |
getAriaValueText | (formattedValue: string, value: number | null) => string | the Root's aria-valuetext instead of the formatted value; it receives "" and null when indeterminate |
Label
| prop | type | default | description |
|---|---|---|---|
id | string | generated | the id the Root's aria-labelledby points at |
Value
No props of its own. Its children replace the formatted value: a function
(formattedValue, value) => ReactNode in React, the default scoped slot
{ formattedValue, value } in Vue, the directive's formattedValue() and value() signals in
Angular.
Track
No props of its own.
Indicator
No props of its own.
State and part attributes
Every part carries exactly one of data-indeterminate, data-progressing, data-complete.
| part | attributes |
|---|---|
| Root | role="progressbar", aria-valuemin, aria-valuemax, aria-valuenow (the clamped value; absent when indeterminate), aria-valuetext (the formatted value, or getAriaValueText's; absent when indeterminate without it), aria-labelledby (the Label, while one is rendered) |
| Label | id |
| Value, Track | the status |
| Indicator | structural inline style while not indeterminate: inset-inline-start: 0, inline-size: <percent>% and --progress-indicator-size: <percent>%; none when indeterminate |
Keyboard
None: a progress bar is not focusable.
Exports
| entry | exports |
|---|---|
@fragiola/primitives-react/progress | Progress, ProgressIndicatorProps, ProgressLabelProps, ProgressRootProps, ProgressState, ProgressStatus, ProgressTrackProps, ProgressValueProps, RenderProp |
@fragiola/primitives-vue/progress | Progress, ProgressLabelProps, ProgressRootProps, ProgressState, ProgressStatus, ProgressValueSlotProps, ProgressValueSlots, RenderSlotProps |
@fragiola/primitives-angular/progress | ProgressIndicator, ProgressLabel, ProgressRoot, ProgressState, ProgressStatus, ProgressTrack, ProgressValue |