Skip to main content

Progress

Show measurable or indeterminate task progress.

Uploading design.fig65%
Props
Slots

Anatomy#

Progress [component; slot=root]
├── label [slot]
├── value [slot]
└── track [slot]
    └── indicator [slot]

Usage#

Use Progress for measurable task completion or for work whose end is not yet known. Choose a determinate value only when it represents real progress. For a loading placeholder of content structure, use Skeleton.

import { Progress } from 'moraine'

export function Example() {
  return <Progress value={40} max={100} aria-label="Upload progress" />
}

Progress models#

  • Determinate: pass a numeric value from 0 to max (default 100); values outside the range are clamped.
  • Indeterminate: omit value when total progress is unknown. Indeterminate bars omit aria-valuenow, set aria-valuetext from the progress.indeterminate locale message, and support animation ('carousel', 'reverse', 'swing', or 'elastic').
<Progress value={65} aria-label="Uploading design.fig" />
<Progress aria-label="Scanning for malware" />

Label and value#

Supply aria-label (or a labelling relationship) when surrounding context does not name the operation:

  • label: fills the label slot. A string label also serves as the default aria-label unless an explicit aria-label is passed.
  • valueLabel: renders the formatted percentage in the value slot (hidden while indeterminate). Pass a function ({ value, max, percent }) => string to customize both the displayed text and aria-valuetext. Without valueLabel, aria-valuetext still reports the formatted percentage.
<Progress value={82} label="Downloading installation bundle" valueLabel aria-label="Download" />
<Progress value={40} valueLabel={({ percent }) => `${percent}% complete`} aria-label="Export" />

Orientation#

Progress fills horizontally from left to right by default. Set orientation="vertical" for a bar that fills from the bottom (such as a battery or level meter), growing to its container height with a 9rem minimum.

<Progress value={72} orientation="vertical" aria-label="Battery level" />

Number format#

formatOptions accepts Intl.NumberFormat options and formats both the displayed value and aria-valuetext using the provider locale:

  • Without formatOptions, the text defaults to the completed percentage rounded to two decimal places.
  • With formatOptions, it formats the raw value (like Slider) rather than the completed fraction, so { style: 'percent' } expects max={1}.
  • A custom valueLabel formatter function takes precedence over formatOptions.
<Progress value={0.75} max={1} valueLabel formatOptions={{ style: 'percent' }} aria-label="Setup" />
<Progress value={42} valueLabel formatOptions={{ style: 'unit', unit: 'megabyte' }} aria-label="Upload" />

Examples#

Determinate and indeterminate#

Pass a numeric value for determinate progress, or omit value for an indeterminate bar.

import { Progress } from 'moraine'

export function Models() {
  return (
    <div class="max-w-md w-full space-y-4">
      <Progress label="Uploading design.fig" value={65} />
      <Progress label="Scanning for malware" />
    </div>
  )
}

Label and value#

Set label and valueLabel when the operation name and percentage should appear with the bar. A string label also names the progressbar, so no separate aria-label is needed.

import { Progress } from 'moraine'

export function Semantics() {
  return (
    <div class="max-w-md w-full">
      <Progress label="Downloading installation bundle" value={82} valueLabel />
    </div>
  )
}

Orientation#

Use orientation="vertical" for level meters that fill from the bottom.

import { Progress } from 'moraine'

export function Orientation() {
  return (
    <div class="flex gap-8 items-end">
      <div class="max-w-md w-full">
        <Progress label="Disk usage" value={72} valueLabel orientation="horizontal" />
      </div>
      <Progress value={72} orientation="vertical" aria-label="Battery level" />
    </div>
  )
}

API Reference#

Attributes#

Attributes
data-indeterminate
Slot: progressprogress-indicator
Description: Present when the checkbox or progress state is indeterminate.
data-progress
Slot: progressprogress-indicator
Description: Stores whether determinate progress is loading or complete.

Props#

Renders a <div> element by default.

Prop