Skip to main content
  1. Docs
  2. Components
  3. Feedback

Progress

A task advancing: an upload, an import. Unknown while its end is unknown; its tone says how it ended.

Import
@qeetrix/react
Status
StableSince 0.0.2
Renders
<div role="progressbar">Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

Import

progress.tsx
// From the package: a build keeps only what it uses.
import { Progress } from "@qeetrix/react";

// Or from its own path.
import { Progress } from "@qeetrix/react/progress";

02

Props

And every native attribute of the element it renders.

PropTypeDefaultWhat it does
valuenumber | nullrequiredHow far, from min to max; null while that's unknown.
min · maxnumber0 · 100An empty track, and a full one.
labelReactNode—The visible label; without one, an aria-label.
showValuebooleanfalseThe formatted value at the header's end.
formatIntl.NumberFormatOptionsa percentageHow the value is written and read.
tone"brand" | "success" | "danger""brand"success for a task that finished, danger for one that failed.
localestringthe provider'sFormats the value.

03

Parts

Each part carries a data-slot, for tests and placement.

data-slotElementWhat it is
progress<div role="progressbar">aria-valuenow; data-tone.
progress-header<div>The label and the value.
progress-track<div>The track.
progress-indicator<div>The bar.

04

From an upload

Feed it the bytes sent; when it ends, turn it success or danger and say so in the label.

upload.tsx
const [sent, setSent] = useState(0);
xhr.upload.onprogress = (event) => setSent(event.loaded / event.total);

<Progress label={label} showValue value={sent * 100} tone={failed ? "danger" : done ? "success" : "brand"} />
Next — ProgressAccessibility