antlitz
Menu

Progress

A bar showing how far along a task is. For work with no proportion to show, reach for Spinner instead.

import { Progress } from "antlitz";

API

PropTypeDefault
maxnumber100
radius"none" | "sm" | "md" | "lg" | "full"none
size"sm" | "md" | "lg"md
valuenumber—
variant"solid" | "danger"solid

value is required and is clamped into 0–max, so an out-of-range number from a calculation cannot render a bar wider than its track. NaN, or a max of zero, renders an empty bar rather than a full one.

Usage

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

Sizes

export function Sizes() {
  return (
    <>
      <Progress size="sm" value={30} aria-label="Small" />
      <Progress size="md" value={50} aria-label="Medium" />
      <Progress size="lg" value={70} aria-label="Large" />
    </>
  );
}

Radius

export function Radius() {
  return RADII.map((radius) => (
    <Progress key={radius} radius={radius} value={60} aria-label={radius} />
  ));
}

Danger

export function Danger() {
  return <Progress value={96} variant="danger" aria-label="Storage used" />;
}

variant="danger" turns the fill red. Use it when the value is a problem rather than a milestone: a quota nearly spent, a budget overrun. Colour alone is not announced, so say the same thing in the label or the text beside the bar.

A progress bar is not a form control, so aria-invalid has no meaning on it and does not change its colour.

Scale

Step 3 of 4

export function Scale() {
  return (
    <>
      <Progress value={3} max={4} aria-label="Step 3 of 4" />
      <Text size="sm" tone="subtle">
        Step 3 of 4
      </Text>
    </>
  );
}

max sets the upper bound. Steps and counts read better against their own scale than converted to a percentage, and the number a screen reader announces comes from max too.

Labelling

Storage used
export function Labelled() {
  return (
    <>
      <Text as="span" id="quota" size="sm">
        Storage used
      </Text>
      <Progress value={62} aria-labelledby="quota" />
    </>
  );
}

A progress bar needs an accessible name. Pass aria-label, or point aria-labelledby at text already on the page — the second is better when the label is visible, since the two cannot then drift apart.

Not a native progress

This is a div with role="progressbar" rather than a native progress element, which can only be styled through engine-specific pseudo-elements — ::-webkit-progress-value, ::-moz-progress-bar — that no utility can reach and that disagree on rounding and transitions. The role carries the same information to assistive technology.