Progress indicator
Reports how far a task has come, or that one is under way, as a bar, a ring or a loader.
import { ProgressBar } from '@slotted/react/progress-indicator';export default function ProgressIndicatorBasic() { return <ProgressBar label="Uploading invoices" showValue value={40} />;}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { ProgressBar, ProgressCircle, Loader, ProgressIndicatorDefaultsProvider } from '@slotted/react';Value and range
value is measured against min and max, which default to 0 and 100. The number is written with Intl in the page language, as a percentage unless format takes another form: the second bar runs from 200 to 400 and the third reads in megabytes. valueText replaces both the spoken and the rendered number for a quantity the component cannot compute, such as “3 of 7 files”. A value outside the range is clamped, and the clamped value is the one drawn and the one announced. showValue renders the number beside the name. A bar that reaches its maximum carries data-complete.
import { ProgressBar } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';export default function ProgressIndicatorDeterminate() { return ( <Stack gap={5}> <ProgressBar label="Copying files" showValue value={40} /> <ProgressBar label="Pallets staged" max={400} min={200} showValue value={260} /> <ProgressBar format={{ style: 'unit', unit: 'megabyte', unitDisplay: 'narrow' }} label="Downloading carrier manifest" max={512} showValue value={128} /> <ProgressBar label="Importing orders" max={7} showValue value={3} valueText="3 of 7 files" /> <ProgressBar label="Backup finished" showValue value={100} /> </Stack> );}Progress while a task runs
Pass the current value from state and the bar follows it. The name comes from label; an indicator without a name, an aria-label or decorative logs a warning in development. ARIA asks the page to mark the region that waits with aria-busy and to point aria-describedby at the indicator. The component writes neither, because the region belongs to the page. Press the button: the import takes about three seconds.
import { useEffect, useState } from 'react';import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { ProgressBar } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';/** Stands in for an import that reports how much of it is done. */const STEP = 8;export default function ProgressIndicatorLive() { const [started, setStarted] = useState(false); const [value, setValue] = useState(0); const running = started && value < 100; useEffect(() => { if (!running) return undefined; const timer = setInterval(() => setValue((current) => Math.min(100, current + STEP)), 250); return () => clearInterval(timer); }, [running]); function handleStart() { setValue(0); setStarted(true); } return ( <Stack aria-busy={running || undefined} aria-describedby="import-progress" gap={4}> <Inline> <Button onClick={handleStart}>Start import</Button> </Inline> <ProgressBar id="import-progress" label="Importing orders" showValue value={value} /> <Text size="sm" tone="muted"> {value === 100 ? '1,240 orders imported.' : 'Northwind Retail, 1,240 orders.'} </Text> </Stack> );}Unknown duration
Leave value out and the indicator reports a wait instead of a quantity: aria-valuenow is omitted, the whole track shows, and showValue renders no number. Pass null to state that the number is not known yet. Passing 0 would state that nothing has been done.
import { ProgressBar, ProgressCircle } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';export default function ProgressIndicatorIndeterminate() { return ( <Stack gap={5}> <ProgressBar label="Preparing your export" /> <ProgressCircle label="Checking availability" /> </Stack> );}Sizes
size is the thickness of the bar, the diameter of the ring and the box of the loader. Rings and loaders read the control height scale, so one placed beside a control of the same step is as tall as that control. Here the rings and loaders hide their label with hideLabel, which keeps it as the accessible name.
import { Inline } from '@slotted/react/inline';import { Loader, ProgressBar, ProgressCircle } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';export default function ProgressIndicatorSizes() { return ( <Stack gap={5}> <ProgressBar label="Small" showValue size="sm" value={55} /> <ProgressBar label="Medium" showValue size="md" value={55} /> <ProgressBar label="Large" showValue size="lg" value={55} /> <Inline align="center" gap={4}> <ProgressCircle hideLabel label="Small ring" size="sm" value={55} /> <ProgressCircle hideLabel label="Medium ring" size="md" value={55} /> <ProgressCircle hideLabel label="Large ring" size="lg" value={55} /> </Inline> <Inline align="center" gap={4}> <Loader hideLabel label="Small loader" size="sm" /> <Loader hideLabel label="Medium loader" size="md" /> <Loader hideLabel label="Large loader" size="lg" /> </Inline> </Stack> );}Tones
tone colors the indicator and tints its track. The six tones carry meaning through the label beside them, never through color alone: accent for work in hand, secondary for a background job, info for a sync, success for work that landed, warning for a quota nearly spent and danger for a transfer that failed.
import { ProgressBar } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';export default function ProgressIndicatorTones() { return ( <Stack gap={5}> <ProgressBar label="Uploading invoices" showValue value={62} /> <ProgressBar label="Reindexing the catalog" showValue tone="secondary" value={62} /> <ProgressBar label="Syncing carrier rates" showValue tone="info" value={62} /> <ProgressBar label="Backup complete" showValue tone="success" value={100} /> <ProgressBar label="Storage used" showValue tone="warning" value={88} /> <ProgressBar label="Transfer failed" showValue tone="danger" value={41} /> </Stack> );}Wave
wave draws the active part of the bar and of the ring as a wave. The ring grows a fifth to make room for its crests. The amplitude follows the value: flat below 6 per cent, full from 16 to 84 per cent and flat again from 96, so a bar at the start or at the end reads as a plain fill. A bar with no value is wavy along its whole length.
import { ProgressBar, ProgressCircle } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';export default function ProgressIndicatorWave() { return ( <Stack gap={5}> <ProgressBar label="Rendering the report" showValue size="lg" value={62} wave /> <ProgressBar label="Preparing your export" size="lg" wave /> <ProgressCircle label="Rendering the report" showValue size="lg" value={62} wave /> </Stack> );}Buffer
buffer states a second quantity on the bar: the lighter band is what has arrived, and the indicator is what has been processed. It is never drawn behind the value. The second bar has the same value with no buffer.
import { ProgressBar } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';export default function ProgressIndicatorBuffer() { return ( <Stack gap={5}> <ProgressBar buffer={72} label="Processing uploaded pages" showValue size="lg" value={34} /> <ProgressBar label="The same value without a buffer" showValue size="lg" value={34} /> </Stack> );}Loader
Loader keeps a short wait of unknown duration company with a shape that morphs while it turns. It measures nothing and takes no value. contained adds a rounded container behind the shape, for a photograph or a colored surface where a bare shape has no ground. decorative removes the loader from the accessibility tree, with no role, no range and no name: use it only when the text beside it already says what is happening, as the last row does. A wait whose structure is known belongs to a skeleton, and a control that started the work shows its own loading state.
import { Inline } from '@slotted/react/inline';import { Loader } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function ProgressIndicatorLoader() { return ( <Stack align="start" gap={5}> <Loader label="Signing you in" /> <Loader contained label="Checking warehouse access" size="lg" /> <Inline align="center" gap={3}> <Loader decorative size="sm" /> <Text size="sm">Importing contacts, 62% done.</Text> </Inline> </Stack> );}Edge of a box
placement="edge-start" and placement="edge-end" stand the bar on the block-start or block-end edge of the nearest positioned box, the whole inline size of that box, over the line the edge already draws. The card is that box here. The bar has no track and no radius, hides its label while keeping it as the name, and grows out of its edge and back into it. loading shows and withdraws it. Use it for a refresh of data already on screen, which keeps its values while the bar runs. In an application, AppShellProgress and PageHeaderProgress place such a bar in the app shell and in the page header.
Open orders
The bars stand on the top and bottom edges of this card.import { useEffect, useRef, useState } from 'react';import { Button } from '@slotted/react/button';import { Card, CardBody, CardFooter, CardHeader } from '@slotted/react/card';import { Inline } from '@slotted/react/inline';import { ProgressBar } from '@slotted/react/progress-indicator';import { Heading, Text } from '@slotted/react/typography';/** Stands in for a refresh and for a save that reports how much of it is done. */const REFRESH_MS = 2500;const SAVE_STEP = 10;export default function ProgressIndicatorEdges() { const [refreshing, setRefreshing] = useState(false); const [saved, setSaved] = useState<number | null>(null); const refreshTimer = useRef<ReturnType<typeof setTimeout>>(undefined); const saving = saved !== null && saved < 100; useEffect(() => () => clearTimeout(refreshTimer.current), []); useEffect(() => { if (!saving) return undefined; const timer = setInterval( () => setSaved((current) => Math.min(100, (current ?? 0) + SAVE_STEP)), 250, ); return () => clearInterval(timer); }, [saving]); function handleRefresh() { clearTimeout(refreshTimer.current); setRefreshing(true); refreshTimer.current = setTimeout(() => setRefreshing(false), REFRESH_MS); } function handleSave() { setSaved(0); } return ( <Card> <ProgressBar label="Refreshing orders" loading={refreshing} placement="edge-start" /> <CardHeader> <Heading level={2} size="md"> Open orders </Heading> <Text size="sm" tone="muted"> The bars stand on the top and bottom edges of this card. </Text> </CardHeader> <CardBody> <Text size="sm">38 orders are waiting for a carrier pickup.</Text> </CardBody> <CardFooter> <Inline gap={3}> <Button onClick={handleRefresh} variant="outline"> Refresh orders </Button> <Button onClick={handleSave} variant="outline"> Save view </Button> </Inline> </CardFooter> <ProgressBar label="Saving the view" loading={saving} placement="edge-end" value={saved} /> </Card> );}Page
placement="page" pins the bar to the top edge of the viewport, squares its corners and drops its track. The label is hidden and stays as the accessible name. A navigation is the wait this placement answers, so the example sets delay and minDuration on the bar, and a response faster than 200 ms draws nothing.
import { useEffect, useRef, useState } from 'react';import { Button } from '@slotted/react/button';import { ProgressBar } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';/** Stands in for the navigation to a report. */const NAVIGATION_MS = 1800;export default function ProgressIndicatorPage() { const [navigating, setNavigating] = useState(false); const timer = useRef<ReturnType<typeof setTimeout>>(undefined); useEffect(() => () => clearTimeout(timer.current), []); function handleNavigate() { clearTimeout(timer.current); setNavigating(true); timer.current = setTimeout(() => setNavigating(false), NAVIGATION_MS); } return ( <Stack align="start" gap={3}> <ProgressBar delay={200} label="Loading page" loading={navigating} minDuration={400} placement="page" /> <Button onClick={handleNavigate}>Open the Q3 report</Button> <Text size="sm" tone="muted"> The bar crosses the top of the viewport while the report loads. </Text> </Stack> );}Timing
loading states whether the wait is still on. delay is the time in milliseconds the wait must last before anything is drawn, and until then the root carries hidden. minDuration is the time an indicator that did appear is held before it is withdrawn, so it does not appear and vanish within one frame. The recommended pair is 200 and 400, and a defaults provider sets it once for every indicator below it: ProgressIndicatorDefaultsProvider in React, provideProgressIndicatorDefaults in Angular. onWithdraw in React and withdraw in Angular fire when the indicator actually leaves the page, which is later than loading turning false whenever minDuration is holding it. The fast response lasts 150 ms and the slow one 1.5 s.
import { useEffect, useRef, useState } from 'react';import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { ProgressBar } from '@slotted/react/progress-indicator';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';/** Stand in for a response from a warm cache and for one from a distant region. */const FAST_MS = 150;const SLOW_MS = 1500;export default function ProgressIndicatorTiming() { const [pending, setPending] = useState(false); const [withdrawals, setWithdrawals] = useState(0); const timer = useRef<ReturnType<typeof setTimeout>>(undefined); useEffect(() => () => clearTimeout(timer.current), []); function handleRequest(duration: number) { clearTimeout(timer.current); setPending(true); timer.current = setTimeout(() => setPending(false), duration); } return ( <Stack gap={4}> <Inline gap={3}> <Button onClick={() => handleRequest(FAST_MS)} variant="outline"> Fast response </Button> <Button onClick={() => handleRequest(SLOW_MS)} variant="outline"> Slow response </Button> </Inline> <Text size="sm" tone="muted"> No timing </Text> <ProgressBar label="Loading shipments" loading={pending} /> <Text size="sm" tone="muted"> delay 200 ms, minDuration 400 ms </Text> <ProgressBar delay={200} label="Loading shipments, timed" loading={pending} minDuration={400} onWithdraw={() => setWithdrawals((count) => count + 1)} /> <Text size="sm">Times the timed bar left the page: {withdrawals}</Text> </Stack> );}Accessibility
- The root carries role="progressbar" with aria-valuemin and aria-valuemax written out, and aria-valuenow only while there is a value. ARIA 1.3 asks an author to omit aria-valuenow when the value is indeterminate, and the omission is what says “in progress, and nobody knows how far”.
- A value outside the range is clamped, and the clamped value is what both the paint and aria-valuenow report — so the picture a reader sees and the number a reader hears cannot disagree. Progress is usually computed from numbers an application does not fully control.
- progressbar carries Children Presentational: True in ARIA 1.3, which means everything inside the root is pruned from the accessibility tree. The label reaches a reader through aria-labelledby and the number through aria-valuetext; anything else you put inside is silent. A live region inside an indicator is silent too, which is why the words that carry a wait belong to InlineMessage beside it rather than to a hidden region within it.
- An accessible name is required, and there are three ways to give one: label, your own aria-label or aria-labelledby, or decorative for a spinner beside text that already says what is happening. With none of the three, development warns and the indicator still renders: a nameless bar reports visually, and taking a screen down mid-upload is worse than the defect.
- If the indicator describes the loading of a region, ARIA asks you to set aria-busy on that region and point aria-describedby at the indicator. The component writes neither, because the region is yours.
- Under prefers-reduced-motion every loop stops rather than shortening — an animation that repeats forever needs to stop, and the indeterminate indicator rests at a length that reads as a fraction rather than as nought or as full. The cost is real: a still indicator says nothing on its own, so the name matters more, and the loader is best given a visible label.
- The indicator is a tone’s text role, which the theme holds to the 4.5:1 reading ratio against every surface — more than the 3:1 WCAG 2.2 1.4.11 asks of a meaningful graphic — in all three color schemes. Under forced colors the track keeps a ButtonBorder edge and the indicator takes Highlight, so the geometry survives a palette the family did not choose.
API
progressIndicator
Props
valuenumber | nullDefault null (indeterminate)- On ProgressBar, ProgressCircleThe quantity. Absent or null is a wait rather than nought per cent, and a value outside the range is clamped
minnumberDefault0- On ProgressBar, ProgressCircleThe bottom of the range, and what aria-valuemin reports
maxnumberDefault100- On ProgressBar, ProgressCircleThe top of the range, and what aria-valuemax reports. Reaching it writes data-complete
buffernumber | null- On ProgressBarA second, further quantity: received but not yet processed. Never painted behind the value
sizesm | md | lgDefaultmd- On all threeThe bar’s thickness, the ring’s diameter, the loader’s box. Rings and loaders read the control height scale, so they match a control of the same step
toneaccent | secondary | info | success | warning | dangerDefaultaccent- On all threeThe six tones the theme provides. The indicator is the tone’s text role and the track is a computed tint of it
labelstring- On all threeThe rendered accessible name. Without it, or aria-label, or decorative, a development warning names the component
hideLabelbooleanDefaultfalse- On all threeClips the label with visually-hidden and keeps it as the name. A page-level bar sets it by itself
showValuebooleanDefaultfalse- On ProgressBar, ProgressCircleWhether the formatted number is rendered beside the name. A wait needs no number to be understood
valueTextstring- On ProgressBar, ProgressCircleA string the component cannot compute — “3 of 7 files”. It becomes both aria-valuetext and the rendered value
formatIntl.NumberFormatOptions- On ProgressBar, ProgressCircleHow the number is written, applied to the value. Absent, the ratio is written as a percentage
localestring- On ProgressBar, ProgressCircleBCP 47. Absent, the provider’s, then the runtime’s own
wavebooleanDefaultfalse- On ProgressBar, ProgressCircleM3 Expressive’s wavy active indicator. The ring grows a fifth to make room for its crests
containedbooleanDefaultfalse- On LoaderM3’s fully rounded container behind the morphing shape, at M3’s own 38:48 ratio
placementinline | page | edge-start | edge-endDefaultinline- On ProgressBarpage pins the bar to the top edge of the viewport, squares it, drops its track and reads the sticky stacking token; edge-start and edge-end stand it on the block-start or block-end edge of the nearest positioned box, over the line that edge draws. Every value but inline clips the label and grows the bar out of its edge
decorativebooleanDefaultfalse- On all threeTakes the indicator out of the accessibility tree — no role, no range, no name — for a spinner beside text that already says what is happening
loadingbooleanDefaulttrue- On all threeWhether the wait is still on. false withdraws the indicator, honoring minDuration
delaynumberDefault0- On all threeMilliseconds the wait must last before anything is painted. Until then the root carries hidden — no box and no reserved band
minDurationnumberDefault0- On all threeMilliseconds an indicator that did appear is held before it is withdrawn
Events
| Name | Payload | When |
|---|---|---|
onWithdraw | void | The indicator actually leaves the page — later than loading turning false whenever minDuration is still holding it. It is the moment an application unmounts the card the indicator was in. |
Composition
render(props) => ReactNode- On all threeSubstitutes the rendered root. Every data attribute, the role, the range and the percentage custom property are handed to it
refRef<HTMLDivElement>- On all threeReaches the root; each component’s props are that element’s, extended
ProgressIndicatorDefaultsProviderProgressIndicatorDefaults- On ApplicationSets size, tone, delay, minDuration, locale and label once for everything below it; a prop on an indicator still wins
aria-busy, aria-describedbyboolean, string- On Your own regionARIA asks a consumer to write both on the region that is loading, pointing at the indicator’s id. The component cannot: the region is yours
InlineMessageReactNode- On Beside the indicatorThe words that carry the wait. role="progressbar" prunes its own subtree, so a message inside an indicator is never heard — it belongs next to one
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | div | Yes | The box, and the element that carries role="progressbar", the range and the states. All three components render it. It is what you position, and what a ref reaches. |
label | span | No | The rendered accessible name, referenced by aria-labelledby. Present when label is set; clipped by visually-hidden when hideLabel is, and a page-level bar clips it by itself. |
value | span | No | The formatted number, in tabular figures so a counting bar does not jitter. Present when showValue is set and the indicator has a value to write. |
track | div, or an svg circle | Yes | The ground the indicator is drawn on: painted for the bar, painted for a determinate ring, and transparent for the loader unless contained. The remaining track, the buffer and the stop indicator are drawn on it and are not parts. |
indicator | div, or an svg circle or path | Yes | The quantity: the filled bar, the arc, or the morphing shape. It is what the tone paints and what the motion moves. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every progress indicator inside it.
Progress indicator tokens
| Token | Default |
|---|---|
--slotted-progress-indicator-buffer-color | transparent |
--slotted-progress-indicator-buffer-percent | 0 |
--slotted-progress-indicator-gap | var(--_thickness) |
--slotted-progress-indicator-indicator-color | var(--slotted-tone-accent-text) |
--slotted-progress-indicator-percent | 0 |
--slotted-progress-indicator-position | absolute |
--slotted-progress-indicator-radius | var(--slotted-radius-full, 9999px) |
--slotted-progress-indicator-size | var(--slotted-control-height-md, 34px) |
--slotted-progress-indicator-stroke | 6 |
--slotted-progress-indicator-thickness | var(--slotted-space-3, 0.375rem) |
--slotted-progress-indicator-track-color | color-mix(in oklab, var(--_ink) 24%, var(--slotted-surface)) |
--slotted-progress-indicator-travel-size | — |
--slotted-progress-indicator-travel-start | — |
--slotted-progress-indicator-wave-amplitude | — |
--slotted-progress-indicator-wave-phase | — |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-border-strong | Set per scheme by the theme |
--slotted-border-width-thin | 1px |
--slotted-control-font-family | var(--slotted-font-family-sans) |
--slotted-control-font-size-lg | comfortable 14px · compact 13px · dense 12px |
--slotted-control-font-size-md | comfortable 13px · compact 12px · dense 12px |
--slotted-control-font-size-sm | comfortable 12px · compact 12px · dense 12px |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-duration-long | 320ms |
--slotted-duration-loop | 1.1s |
--slotted-duration-loop-slow | 1.6s |
--slotted-duration-medium | 200ms |
--slotted-duration-short | 120ms |
--slotted-easing-emphasized | cubic-bezier(0.3, 0, 0, 1.3) |
--slotted-easing-enter | cubic-bezier(0.05, 0.7, 0.1, 1) |
--slotted-easing-exit | cubic-bezier(0.3, 0, 0.8, 0.15) |
--slotted-easing-standard | cubic-bezier(0.2, 0, 0, 1) |
--slotted-line-height-md | 1.5 |
--slotted-radius-full | 9999px |
--slotted-radius-none | 0px |
--slotted-space-2 | 0.25rem |
--slotted-space-3 | 0.375rem |
--slotted-space-4 | 0.5rem |
--slotted-surface | Set per scheme by the theme |
--slotted-text | Set per scheme by the theme |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-accent-text | Set per scheme by the theme |
--slotted-tone-danger-text | Set per scheme by the theme |
--slotted-tone-info-text | Set per scheme by the theme |
--slotted-tone-success-text | Set per scheme by the theme |
--slotted-tone-warning-text | Set per scheme by the theme |
--slotted-z-index-sticky | 100 |