Live demo
Demo source
Overview
Use a progress bar for a task that takes a while and whose progress your application can measure, such as an import or an upload. For a short wait without a measure, a loader is enough. The bar isn't interactive.
Anatomy
A progress bar showing 46%, with three callouts: 1 marks the track, 2 the filled part, and 3 the percentage value.
- Track: the full width of the task.
- Fill:
valueas a share ofmax(default 100). Values outside the range are clamped. - Percentage (optional,
showValue): the rounded share, such as "75%".
Properties
| Design setting | Code | Mapping |
|---|---|---|
| Feedback | feedback | neutral, success or error; the application sets the outcome. |
| Indeterminate | indeterminate | Animates a segment and hides the percentage. Use with neutral feedback. |
| Value | value, max | The fill is the clamped ratio of value to max. |
| Show value | showValue | Displays a rounded percentage. |
| Accessible name | aria-label, aria-labelledby | Identifies the task being measured. |
Look and feel
Use neutral feedback during work, success after completion, and error when
work fails. The design shows a full success track: in this implementation,
set value to max as well as feedback="success"; feedback alone changes
only the colour. For an error, retain the last measured value.
Indeterminate progress moves a segment along the track for work of unknown duration. It hides the percentage and stops animating under reduced-motion preferences. End indeterminate mode before showing success or error. Both modes support Spark and Ocean in light and dark themes.
Accessibility
Name each bar and provide visible status text so colour does not carry the
outcome alone. The host exposes role="progressbar", a minimum of 0 and a
maximum of 100; aria-valuenow contains the percentage, regardless of the
application's max. It is omitted for indeterminate progress.
Usage
Use measured progress when available. Reaching 100% does not prove that the server accepted the work: set success only after completion is confirmed. Use indeterminate progress only while the result is pending.
Related
File upload uses the bar inside each file tile. Use a loader when activity needs no progress track.