Progress Bar
ProgressBar communicates the progress of a task or loading operation.
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';
<ProgressBar value={65}>
<ProgressBar.Header>
<ProgressBar.Label>Uploading assets</ProgressBar.Label>
<ProgressBar.Value />
</ProgressBar.Header>
<ProgressBar.Track />
<ProgressBar.Description>12 of 18 files uploaded</ProgressBar.Description>
</ProgressBar>Installation
pnpm dlx wideset add progress-bar
Copies the component and any Wideset components it uses into your project.
Examples
Types
The bar spans its container and carries a label, the percentage and a description, so it suits an upload or a long task the user is watching. The circle is a compact ring, with the percentage beside it when you compose ProgressBar.Value, for a table row, a file list or a sidebar where a full-width bar does not fit; it has no label, so name it with aria-label. Both announce their value to screen readers as a progressbar.
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';
export default function ProgressBarTypes() {
return (
<div className="gap-ws-12 flex w-[20rem] max-w-full flex-col">
<ProgressBar type="bar" value={50}>
<ProgressBar.Header>
<ProgressBar.Label>Uploading assets</ProgressBar.Label>
<ProgressBar.Value />
</ProgressBar.Header>
<ProgressBar.Track />
<ProgressBar.Description>9 of 18 files uploaded</ProgressBar.Description>
</ProgressBar>
<ProgressBar type="circle" value={50} aria-label="Uploading assets">
<ProgressBar.Value />
<ProgressBar.Track />
</ProgressBar>
</div>
);
}Statuses
Default shows progress that is still running. Switch to success once the task completes and to error when it fails, and say in the description what happened and what to do next. The description takes its colour from the bar, and success and error add an icon to it, so colour is not the only signal.
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';
const states = [
{ status: 'default', value: 50, description: '9 of 18 files uploaded' },
{ status: 'success', value: 100, description: 'All 18 files uploaded' },
{ status: 'error', value: 50, description: 'Upload stopped: 9 files failed. Try again.' },
] as const;
export default function ProgressBarStatuses() {
return (
<div className="gap-ws-12 flex w-[20rem] max-w-full flex-col">
{states.map(({ status, value, description }) => (
<ProgressBar key={status} status={status} value={value}>
<ProgressBar.Header>
<ProgressBar.Label>Uploading assets</ProgressBar.Label>
<ProgressBar.Value />
</ProgressBar.Header>
<ProgressBar.Track />
<ProgressBar.Description>{description}</ProgressBar.Description>
</ProgressBar>
))}
</div>
);
}Composition
Compose the parts to change what the bar shows. Give ProgressBar.Value children to show a count instead of the percentage, and set max on the root so the fill and the screen reader value follow it. The label names the progressbar and the description describes it. Without children the bar and the circle render only their track, so compose ProgressBar.Value for the percentage.
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';
export default function ProgressBarComposition() {
const uploaded = 32;
const total = 40;
return (
<div className="gap-ws-12 flex w-[20rem] max-w-full flex-col">
<ProgressBar value={uploaded} max={total}>
<ProgressBar.Header>
<ProgressBar.Label>Uploading files</ProgressBar.Label>
<ProgressBar.Value>
{uploaded} / {total}
</ProgressBar.Value>
</ProgressBar.Header>
<ProgressBar.Track />
<ProgressBar.Description>{total - uploaded} files remaining</ProgressBar.Description>
</ProgressBar>
<div className="gap-ws-5 flex items-center justify-between">
<span className="typography-label-sm text-ws-static-base">Syncing library</span>
<ProgressBar type="circle" value={80} aria-label="Syncing library">
<ProgressBar.Value />
<ProgressBar.Track />
</ProgressBar>
</div>
</div>
);
}API reference
ProgressBar
| Name | Description | Default |
|---|---|---|
asChild | Renders the root onto its single child element, which then holds the parts, e.g. `<ProgressBar asChild><section>…</section></ProgressBar>`. Without one, the root stays a `<div>`. boolean | — |
children | The parts to render: `ProgressBar.Header`, `.Label`, `.Value`, `.Track`, `.Description`. Without children both types render only their track: the bar, or the ring. ReactNode | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
max | The value that means complete. Defaults to `100`. number | — |
status | State of the task: `default` while it runs, `success` when it finished, `error` when it failed. Sets the colour of the fill, the circle's icon and the description. ProgressBarStatus | 'default' |
type | Shape of the progress indicator: a full-width bar or a compact ring. ProgressBarType | 'bar' |
value | Current progress, clamped between `0` and `max`. A missing or `NaN` value renders `0`. number | — |
Radix Progress.Root is passed through to it. See Radix Progress.Root.ProgressBar.Description
<span> is passed through to it. See MDN: <span>.ProgressBar.Header
<div> is passed through to it. See MDN: <div>.ProgressBar.Label
| Name | Description | Default |
|---|---|---|
children | Label content: plain text or rich content such as formatted text. ReactNode | — |
<label> is passed through to it. See MDN: <label>.ProgressBar.Track
<div> is passed through to it. See MDN: <div>.ProgressBar.Value
| Name | Description | Default |
|---|---|---|
children | Fixed content that replaces the computed value; wins over `formatValue`. Visual only. ReactNode | — |
formatValue | Builds the text from the clamped value and `max`, e.g. `(value, max) => \`${value} / ${max}\``. Visual only: screen readers hear the percentage, or the root's `aria-valuetext` when you set it. ((value: number, max: number) => ReactNode) | — |
<span> is passed through to it. See MDN: <span>.Accessibility
- Both types render
role="progressbar"with the value on the root. - Name it:
ProgressBar.Labelon a bar;aria-labelon a circle. Without either, the name falls back to “Progress”.ProgressBar.Descriptiondescribes it. ProgressBar.Valuetext (formatValueor children) is visual only. Screen readers hear the percentage; setaria-valuetexton the root when the shown value means something else.- Success and error add an icon, so colour is not the only signal.
| Part | Renders | Description |
|---|---|---|
| ProgressBarRenders no element | Radix Progress.Root | Shows how far a task has got, as a bar or a ring. |
| ProgressBar.DescriptionRenders no element | <span> | Helper text below the bar, coloured by the root `status`; it describes the progressbar. |
| ProgressBar.HeaderRenders no element | <div> | The row above the bar holding `ProgressBar.Label` and `ProgressBar.Value` (bar type). |
| ProgressBar.LabelRenders no element | <label> | The visible label; it names the progressbar through `aria-labelledby`. |
| ProgressBar.TrackRenders no element | <div> | The bar's track and fill, or the ring (an icon on success and error) for the circle type. |
| ProgressBar.ValueRenders no element | <span> | The value as text, the percentage by default. |
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';
<ProgressBar value={65}>
<ProgressBar.Header>
<ProgressBar.Label>Uploading assets</ProgressBar.Label>
<ProgressBar.Value />
</ProgressBar.Header>
<ProgressBar.Track />
<ProgressBar.Description>12 of 18 files uploaded</ProgressBar.Description>
</ProgressBar>