- Docs
- Components
- 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
// 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.
| Prop | Type | Default | What it does |
|---|---|---|---|
value | number | null | required | How far, from min to max; null while that's unknown. |
min · max | number | 0 · 100 | An empty track, and a full one. |
label | ReactNode | — | The visible label; without one, an aria-label. |
showValue | boolean | false | The formatted value at the header's end. |
format | Intl.NumberFormatOptions | a percentage | How the value is written and read. |
tone | "brand" | "success" | "danger" | "brand" | success for a task that finished, danger for one that failed. |
locale | string | the provider's | Formats the value. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What 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.
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"} />