Progress
Shows how far a task has come, from 0 to 100%.
Installation
The CLI installs the Radix or Base UI file to match your project.
If your project doesn't have Wisty UI's theme yet, add it once with npx shadcn@latest add @wisty/cosmos. Until then, components keep shadcn's default look. Installation has the details.
When to use
Use it
- A task takes more than a moment and you know how far along it is: an upload, an import, a batch update.
- To show how much of something is used or done, like a quota or a checklist, as a bar.
Usage
Pass a value and a name.
import { Progress } from "@/components/ui/progress"<Progress value={40} aria-label="Import progress" />The bases differ for a label, a value text and classes:
- In Radix projects,
Progressis the bar alone, and classes on it land on the bar. Put the label and the value in your own markup above it, pointaria-labelledbyat the label and mark the value textaria-hidden, as the Importing accounts example shows. - In Base UI projects, put
ProgressLabelandProgressValueinsideProgress. They sit in a row above the bar, and the label names it.ProgressValueshows "25%" on its own, or takes a function of that text, like{(text) => `${text} complete`}. The bar is a track insideProgress, so reach it with[&_[data-slot=progress-track]]:, as the Sizes example does.
Examples
Sizes
SLDS's x-small, small, default and large heights and its circular bar, set with `h-*` and `rounded-full` classes on the bar.
API reference
Progress
Also takes every Radix Progress.Root (opens in a new tab) prop.
SLDS mapping
The bar is slds-progress-bar and the fill is slds-progress-bar__value, as wide as the value. In Base UI projects, ProgressLabel and ProgressValue draw SLDS's labelled bar. SLDS's other heights and the circular bar aren't props: the Sizes example sets them with classes.
Known gaps:
- No vertical bar (
slds-progress-bar_vertical) and no green value (slds-progress-bar__value_success).
Accessibility
- Name every bar:
aria-label, oraria-labelledbypointing at a visible label.ProgressLabeldoes it where it exists. - With
value={null}, the bar is indeterminate: empty, with noaria-valuenow. Passnullwhile you don't know yet, not 0. - Screen readers don't announce the value as it moves. Announce the end of a long task somewhere else, like a toast.
Motion
- The fill doesn't animate, so a change jumps to the new width.
Responsive behavior
- The bar fills its container's width. Put it in a container with a width, or use
max-w-*.
Rules
- Pass
valueas a number from 0 to 100. A fraction like 0.25 draws a near-empty bar. - Don't restyle the colors. They come from the theme.