Progress
A bar that shows users how far a task has come.
A progress bar shows users how far a task has come. Its indicator fills the track as the value moves from the minimum to the maximum, and a label names the task for users and for assistive technology.
Usage
Examples
With Label
Users need to know which task a progress bar measures before its value means anything to them. Placed inside the progress bar, ProgressLabel names that task on screen and gives assistive technology the same name.
With Value
A bar alone leaves users estimating how much of a task remains. With ProgressValue, the value appears as text as well, by default as a percentage of the range, while assistive technology already receives the same figure from the progress bar itself.
Custom Range
Many tasks are counted in units of their own, such as the positions of an order or the shelves of a store. Through min and max the progress bar adopts that range, so the application passes the count as it is and the value still appears as a percentage of the whole.
Custom Value Text
Sometimes a percentage hides the figure users actually work with, such as the number of items still open. A function as the children of ProgressValue then shows the value in the words of the task, while assistive technology keeps announcing the formatted value unless getAriaValueText provides the same words.
Formatted Value
Progress toward a budget or a revenue goal is measured in money rather than in percent. With format, the value appears as a currency amount or in any other unit the task requires, and locale decides how it is written, so users read and assistive technology announces the same figure.
Info
Some processes run in the background and ask nothing of users, such as an import of new product data. Set to "info", variant presents such progress as information only, so users can follow it without feeling asked to act.
Success
A finished task that went as planned, such as a price update that reached every store, lets users move on with confidence. With variant set to "success", the progress bar confirms that outcome, so users need not check the result again.
Warning
Progress can fall behind what a schedule allows, for example a replenishment that must be finished before the store opens. Once variant is set to "warning", the progress bar asks for attention while the task continues, so users can step in before the delay matters.
Destructive
An interrupted upload leaves work that users have to take up again. With variant set to "destructive", the progress bar marks the task as failed, and since the status shows only through color, the label names the failure in words as well.
Complete
A task that has ended should read as ended, so users can turn to the next one. As soon as value reaches max, the progress bar is complete, and assistive technology announces the full amount instead of a share of it.
Controlled
Most progress follows work that happens elsewhere in the interface, such as items that users confirm one at a time. The application holds value in its own state and passes every new count to the progress bar, which keeps pace with each step users complete.
API Reference
Progress
| Prop | variant |
|---|---|
| Type | "default" | "destructive" | "info" | "success" | "warning" |
| Default | "default" |
| Description | Sets the status of the progress bar and colors its indicator to match. |
| Prop | value |
|---|---|
| Type | number | null |
| Default | – |
| Description | Sets the current value. It is required. With null, the progress bar is indeterminate, which tells assistive technology that the amount of work is unknown. |
| Prop | min |
|---|---|
| Type | number |
| Default | 0 |
| Description | Sets the value at which the indicator is empty. |
| Prop | max |
|---|---|
| Type | number |
| Default | 100 |
| Description | Sets the value at which the indicator fills the track and the progress bar is complete. |
| Prop | format |
|---|---|
| Type | Intl.NumberFormatOptions |
| Default | – |
| Description | Sets the options that format the value. ProgressValue shows the formatted value, and assistive technology announces it. Without it, the value is formatted as a percentage of the range from min to max. |
| Prop | locale |
|---|---|
| Type | Intl.LocalesArgument |
| Default | – |
| Description | Sets the locale in which the value is formatted. Without it, the locale of the runtime is used. |
| Prop | getAriaValueText |
|---|---|
| Type | (formattedValue: string, value: number | null) => string |
| Default | – |
| Description | Returns the text that assistive technology announces for the current value. It receives the formatted value and the value. Without it, assistive technology announces the formatted value. |
| Prop | aria-valuetext |
|---|---|
| Type | string |
| Default | – |
| Description | Sets the text that assistive technology announces in place of the formatted value. It takes precedence over getAriaValueText. |
| Prop | render |
|---|---|
| Type | ReactElement | render function |
| Default | – |
| Description | Replaces the native element or composes the progress bar with another component. |
ProgressLabel
| Prop | render |
|---|---|
| Type | ReactElement | render function |
| Default | – |
| Description | Replaces the native element or composes the label with another component. |
ProgressValue
| Prop | children |
|---|---|
| Type | (formattedValue: string | null, value: number | null) => ReactNode |
| Default | – |
| Description | Returns the content that the part shows. The function receives the formatted value and the value. Without it, the part shows the formatted value. |
| Prop | render |
|---|---|
| Type | ReactElement | render function |
| Default | – |
| Description | Replaces the native element or composes the value with another component. |
ProgressTrack
ProgressTrack is the bar that the indicator fills. Progress renders it itself, after its children.
| Prop | render |
|---|---|
| Type | ReactElement | render function |
| Default | – |
| Description | Replaces the native element or composes the track with another component. |
ProgressIndicator
ProgressIndicator fills the track up to the current value. Progress renders it itself, inside ProgressTrack.
| Prop | render |
|---|---|
| Type | ReactElement | render function |
| Default | – |
| Description | Replaces the native element or composes the indicator with another component. |