Progress

How far a task has run, as an accessible bar.

Source
$npx @dinachi/cli@latest add progress
Uploading...
x
value
max
ProgressLabel
ProgressValue

Usage

import {
  Progress,
  ProgressIndicator,
  ProgressLabel,
  ProgressTrack,
  ProgressValue,
} from "@/components/ui/progress"

export function UploadProgress() {
  return (
    <Progress value={40}>
      <ProgressLabel>Upload</ProgressLabel>
      <ProgressValue />
      <ProgressTrack>
        <ProgressIndicator />
      </ProgressTrack>
    </Progress>
  )
}

Examples

Uploading...
x
A label and the formatted value.
import { Progress, ProgressTrack, ProgressIndicator, ProgressLabel, ProgressValue } from '@/components/ui/progress';

export function Example() {
  return (
    <Progress value={75} className="w-full max-w-sm">
      <div className="flex items-center justify-between">
        <ProgressLabel>Uploading...</ProgressLabel>
        <ProgressValue />
      </div>
      <ProgressTrack>
        <ProgressIndicator />
      </ProgressTrack>
    </Progress>
  );
}

Notes

Indeterminate

Pass value={null} when the amount of work is unknown. The root then sets data-indeterminate instead of data-progressing or data-complete; style the indicator from these.

Agent

Not registered with the agent bridge; read from the accessibility tree like any progressbar. Listed as progress with value, min and max, and no actions. Indeterminate, it has no value.

agent.snapshot()
// [{ component: "progress", label: "Upload", value: 40, min: 0, max: 100, actions: [] }]

API

valuenumber | null
Current value. null makes the bar indeterminate.
minnumber = 0
The value at an empty bar.
maxnumber = 100
The value at a full bar.
formatIntl.NumberFormatOptions
Number format for ProgressValue and the announced text.
localeIntl.LocalesArgument
Locale for formatting the value.
getAriaValueText(formattedValue, value) => string
Text announced in place of the number.

Accessibility

  • The root is a progressbar with aria-valuenow, aria-valuemin and aria-valuemax.
  • ProgressLabel names the bar through aria-labelledby. Without one, pass aria-label on Progress.
  • Use getAriaValueText when a percentage is unclear, such as "3 of 10 files".
  • Reduced motion turns off the indicator's width transition.