Fragiola

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.

Upload progress
Gallery

Behaviour

  • Value: a number, clamped to [min, max], or null for an indeterminate progress.
  • Status: indeterminate (null), complete (the clamped value is max), else progressing; every part carries it as one of data-indeterminate, data-complete, data-progressing.
  • Format: without format, the value is written as a percentage of the range ("40%"); with format (Intl.NumberFormatOptions, in locale), as it says ("128 GB"). The Value and the Root's aria-valuetext use it; getAriaValueText wins over it for the Root. Without locale, the runtime's default: a page rendered on a server passes locale, so the server formats as the browser does.
  • Indeterminate: no aria-valuenow and no aria-valuetext (no text of its own), unless getAriaValueText gives one; the Value is empty, and the Indicator has no size: its animation is your CSS, from data-indeterminate.
  • Label: names the Root (aria-labelledby) while it is rendered; or give the Root an aria-label.
  • Indicator: grows from the inline start (right to left in RTL), with --progress-indicator-size for a recipe that draws it otherwise (a ring).

Anatomy

partelementdata-primitives-partrole
Rootdivprogress-rootthe progressbar; holds the value
Labelspanprogress-labelnames the Root
Valuespanprogress-valueshows the formatted value
Trackdivprogress-trackthe rail
Indicatordivprogress-indicatorthe 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

proptypedefaultdescription
valuenumber | nullrequiredthe value, clamped to [min, max]; null for indeterminate
minnumber0the lower bound
maxnumber100the upper bound
formatIntl.NumberFormatOptionsa percentage of the rangehow the Value and aria-valuetext write the value
localestringthe runtime'sthe locale of the format (a BCP 47 tag)
getAriaValueText(formattedValue: string, value: number | null) => stringthe Root's aria-valuetext instead of the formatted value; it receives "" and null when indeterminate

Label

proptypedefaultdescription
idstringgeneratedthe 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.

partattributes
Rootrole="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)
Labelid
Value, Trackthe status
Indicatorstructural 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

entryexports
@fragiola/primitives-react/progressProgress, ProgressIndicatorProps, ProgressLabelProps, ProgressRootProps, ProgressState, ProgressStatus, ProgressTrackProps, ProgressValueProps, RenderProp
@fragiola/primitives-vue/progressProgress, ProgressLabelProps, ProgressRootProps, ProgressState, ProgressStatus, ProgressValueSlotProps, ProgressValueSlots, RenderSlotProps
@fragiola/primitives-angular/progressProgressIndicator, ProgressLabel, ProgressRoot, ProgressState, ProgressStatus, ProgressTrack, ProgressValue