oakoss/ui
Components

Progress

How far along a task is, or that it's running.

SourceReact Aria
Uploading photos62%

Installation

npx shadcn@latest add @oakoss/progress

The item adds the indeterminate animation to your stylesheet's @theme inline.

Usage

import { Progress } from '#/components/ui/feedback/progress';

<Progress label="Uploading photos" value={62} />;

label renders the default layout: the label and value in a row, then the track. For a different layout, pass children instead (see Layout).

Upstream renders its children above a track it always adds, so a ProgressTrack placed by hand draws a second one. Here children replace the whole layout, as Slider's do, and the track draws its own fill, so ProgressIndicator is gone.

Progress shows a task moving toward done. Other states have their own component:

  • Work too short to measure, inside a button or a line of text, is a Spinner.
  • Content that's loading into a known shape is a Skeleton.
  • A value that isn't progress, such as storage used or a password's strength, is a Meter.

For quick tasks, wait about 400ms before showing a bar, so it doesn't flash on and off.

Examples

Intents

intent colors the fill: primary (the default), success, warning, destructive or info. Each keeps 3:1 against the track in light and dark.

Backup100%
Storage86%
Monthly quota97%
Syncing contacts45%

Indeterminate

isIndeterminate is for work whose length isn't known. A short fill slides across the track, from the start of the line in the reading direction. With reduced motion it rests in the middle of the track, which doesn't read as a value.

Preparing your export

Value

formatOptions formats the value for the locale, a percentage by default, and valueLabel replaces it with your own text. minValue and maxValue set the range.

Downloading update96 MB
Setting upStep 3 of 5

Layout

Children replace the default layout, built from ProgressTrack, ProgressLabel and ProgressValue in any order. ProgressValue takes a function of the formatted value to add words around it, and a function child of Progress gets React Aria's render props, such as percentage.

Lessons complete58% done

Accessibility

React Aria renders a progressbar named by its label and handles:

  • Value: aria-valuenow, aria-valuemin and aria-valuemax, and aria-valuetext with the formatted value or your valueLabel.
  • Indeterminate: aria-valuenow and aria-valuetext are left off, so screen readers announce a busy bar rather than a number; this component shows no value then either.

A bar needs a name: label, a ProgressLabel in your layout, or aria-label when there's no visible label. Screen readers mostly don't announce a value as it changes, so for long tasks announce the result when it's done, with a status message or an Alert in a role="status" container. The fill grows by width, logical in right-to-left locales, and takes the system highlight color in Windows High Contrast, where the track keeps a border. React Aria adds no keys.

API

Progress

Extends React Aria's ProgressBar.

Props

Prop

Type

Also accepts all React Aria ProgressBar props. Takes label or children, not both: children replace the layout, and a function child gets React Aria's render props, such as percentage and valueText.

Data attributes

AttributePresent when
data-slotAlways: progress, and on the parts progress-label, progress-value, progress-track, progress-indicator
data-intentAlways on Progress: the fill color

CSS variables

VariableSets
--progress-fillThe fill color

ProgressLabel

React Aria's Label, which names the bar.

ProgressValue

A span with the formatted value, which mounts nothing while the bar is indeterminate.

Props

Prop

Type

Also accepts span props.

ProgressTrack

The track, a span that draws the fill inside it. Accepts span props other than children.