A bar that shows how far a task has got while it runs.
import { Progress } from '@oztix/roadie-components/progress'
Pass a value from 0 to 100 and a label. The value shows beside the label as a percentage.
<Progress value={40} label='Uploading event image' />
Set max for a count, and valueText to say it in words. Screen readers read the same text.
Pass value={null} while the length of the task is unknown. A short bar sweeps across the track until you set a number.
<Progress value={null} label='Preparing export' />
Leave out label for a bare track, such as inside a table row that already names the task. Give it an aria-label instead.
<Progress value={65} aria-label='Upload for Harbourside Lights poster' />
The fill is the accent by default, like Meter. Pass intent to colour the result once a task has ended, such as success or danger.
<div className='grid gap-4'> <Progress value={40} label='Uploading' /> <Progress value={100} label='Upload done' valueText='Done' intent='success' /> <Progress value={72} label='Upload failed' valueText='Failed' intent='danger' /> </div>
The fill eases to each new value. The root carries data-progressing, data-complete or data-indeterminate for styling around it.
Reaching 100% only means the bar has finished. Wait until the app knows how the task ended, then set intent and say the result in valueText. A failed task stays where it stopped, with a Callout that explains what went wrong and offers a way to try again.
Compose the parts for a custom layout. Progress.Value shows the root's valueText when it has one, or takes its own text as children.
<Progress value={120} max={400} label='Importing attendees' valueText='120 of 400' />
Do
Use Progress for work that is underway and will finish, such as an upload, an import or an export.
<Progress value={1842} max={2400} label='Tickets sold' />
Don’t
Don't use Progress for an amount against a limit, such as capacity or tickets sold. Nothing is running there, so use a Meter instead.
Do
Start indeterminate while you wait for a size, then switch to a value as soon as you have one.
Don’t
Don't fake a value or hold a bar at 99%. An honest sweep is better than a number that stops moving.
<Progress value={100} label='Guest list uploaded' valueText='Done' intent='success' />
Do
Set success or danger when the app knows how the task ended, such as when the server confirms the upload.
<Progress value={value} intent={value === 100 ? 'success' : undefined} />
Don’t
Don't turn the bar green at 100%. A finished bar isn't a success yet, because the server can still reject the file.
Do
Say Done or Failed in the label or valueText. For a failure, put a Callout next to the bar with the reason and a Retry action.
Don’t
Don't change only the intent. People who can't tell green from red, and screen reader users, won't know how the task ended.
role='progressbar' with aria-valuemin, aria-valuemax and aria-valuenow. label or Progress.Label names it.valueText becomes aria-valuetext. Without it, screen readers hear the percentage.aria-valuenow, which tells screen readers the amount is unknown.prefers-reduced-motion: reduce the fill jumps to each value, and an indeterminate bar holds still as a soft full-width tint.A string value that provides a user-friendly name for `aria-valuenow`, the current value of the progress bar.
Options to format the value.
Accepts a function which returns a string value that provides a human-readable text alternative for the current value of the progress bar.
The locale used by `Intl.NumberFormat` when formatting the value. Defaults to the user's runtime locale.
The maximum value.
Defaults to 100.
The minimum value.
Defaults to 0.
The current value. The component is indeterminate when value is `null`.
CSS class applied to the element, or a function that returns a class based on the component's state.
A visible label. Without children, the value shows beside it.
Spoken and shown in place of the percentage, such as "120 of 400".
Colours the fill, such as `success` once a task has ended. Without it, the fill is the accent.
No additional props. It forwards all standard HTML attributes to the underlying element.
No additional props. It forwards all standard HTML attributes to the underlying element.
No additional props. It forwards all standard HTML attributes to the underlying element.
CSS class applied to the element, or a function that returns a class based on the component's state.
Text to show, or a function of the formatted and raw value. Defaults to the root's `valueText`, then a percentage.