Progress
Displays an indicator showing the completion progress of a task.
Installation
Install the following dependencies:
Set up the token layer and the StyleX compiler, if you have not already. See
Installation, and paste state-styles.ts from the same
page. The indicator reads Base UI's state through it.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
Usage
value is required and runs from min to max, which default to 0 and
100. Progress renders the track and the indicator itself, so children sit
above the bar.
Label
Use ProgressLabel to name the task and ProgressValue to print the number.
The value is pushed to the end of the row and the track wraps onto its own line
below them.
With no format, ProgressValue divides the value by 100 and prints it as a
percentage. Give it a function child to render something else from the same
numbers.
Controlled
Pass a new value to move the bar. The indicator transitions its width over
300ms, so a jump of any size animates instead of snapping.
Indeterminate
Pass value={null} for a task with no measurable progress. The indicator
becomes a quarter-width bar sweeping the track, ProgressValue renders
nothing, and Base UI writes data-indeterminate on every part.
Under prefers-reduced-motion: reduce the sweep becomes a full-width bar that
fades in and out. Motion is the only way an indeterminate bar shows that work
is happening, so the component replaces it rather than dropping it.
Formatting
Use format to pass Intl.NumberFormat options, which replaces the default
percentage, and locale to pick the locale, which defaults to the runtime's.
API reference
Pass render to replace a part's element or compose it with another component.
Every part wraps the Base UI Progress part of the same name and accepts its
props. See the Base UI reference.
Each part also takes xstyle and className. ProgressIndicator styles itself
from Base UI's state, so it takes style as well. It is real inline CSS, merged
over the compiled style alongside the width Base UI writes.
Progress
| Prop | Type | Default |
|---|---|---|
value | number | null | — |
min | number | 0 |
max | number | 100 |
format | Intl.NumberFormatOptions | — |
locale | Intl.LocalesArgument | — |
getAriaValueText | (formattedValue: string | null, value) => string | — |
xstyle | StyleXStyles | — |
className | string | — |
The root is a <div role="progressbar">. It renders ProgressTrack and
ProgressIndicator after its children, so a bar with no label needs no
children at all.
ProgressValue
| Prop | Type | Default |
|---|---|---|
children | (formattedValue: string | null, value: number | null) => Node | — |
The function child receives "indeterminate" as its first argument while
value is null.
progressStyles
The style maps behind the component. Spread them onto any element.
| Key | What it is |
|---|---|
root | The wrapping row: flex, wrap, gap |
track | The groove: height, fill, inset shadow, clipping |
indicator | The lit bar and its width transition |
indeterminate | The sweep, and its reduced-motion replacement |
label | Label type |
value | Muted, tabular type pushed to the end |
Data attributes
| Attribute | On | Effect |
|---|---|---|
data-slot="progress" | the root | Targets the row from a parent |
data-slot="progress-track" | the track | Targets the groove |
data-slot="progress-indicator" | the bar | Targets the fill |
data-slot="progress-label", data-slot="progress-value" | the text | Targets the label and the number |
data-indeterminate, data-progressing, data-complete | every part | Base UI writes them from the value |