Skip to content
Slotted

Progress indicator

Reports how far a task has come, or that one is under way, as a bar, a ring or a loader.

Uploading invoices40%

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.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes
tsx
import { 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.

Copying files40%
Pallets staged30%
Downloading carrier manifest128MB
Importing orders3 of 7 files
Backup finished100%

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.

Importing orders0%
Northwind Retail, 1,240 orders.

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.

Preparing your export
Checking availability

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.

Small55%
Medium55%
Large55%
Small ring
Medium ring
Large ring
Small loader
Medium loader
Large loader

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.

Uploading invoices62%
Reindexing the catalog62%
Syncing carrier rates62%
Backup complete100%
Storage used88%
Transfer failed41%

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.

Rendering the report62%
Preparing your export
Rendering the report62%

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.

Processing uploaded pages34%
The same value without a buffer34%

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.

Signing you in
Checking warehouse access
Importing contacts, 62% done.

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.
38 orders are waiting for a carrier pickup.

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.

The bar crosses the top of the viewport while the report loads.

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.

No timingdelay 200 ms, minDuration 400 msTimes the timed bar left the page: 0

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
minnumberDefault 0
On ProgressBar, ProgressCircleThe bottom of the range, and what aria-valuemin reports
maxnumberDefault 100
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 | lgDefault md
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 | dangerDefault accent
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
hideLabelbooleanDefault false
On all threeClips the label with visually-hidden and keeps it as the name. A page-level bar sets it by itself
showValuebooleanDefault false
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
wavebooleanDefault false
On ProgressBar, ProgressCircleM3 Expressive’s wavy active indicator. The ring grows a fifth to make room for its crests
containedbooleanDefault false
On LoaderM3’s fully rounded container behind the morphing shape, at M3’s own 38:48 ratio
placementinline | page | edge-start | edge-endDefault inline
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
decorativebooleanDefault false
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
loadingbooleanDefault true
On all threeWhether the wait is still on. false withdraws the indicator, honoring minDuration
delaynumberDefault 0
On all threeMilliseconds the wait must last before anything is painted. Until then the root carries hidden — no box and no reserved band
minDurationnumberDefault 0
On all threeMilliseconds an indicator that did appear is held before it is withdrawn

Events

NamePayloadWhen
onWithdrawvoidThe 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

PartElementRequiredPurpose
rootdivYesThe 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.
labelspanNoThe 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.
valuespanNoThe 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.
trackdiv, or an svg circleYesThe 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.
indicatordiv, or an svg circle or pathYesThe 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

TokenDefault
--slotted-progress-indicator-buffer-colortransparent
--slotted-progress-indicator-buffer-percent0
--slotted-progress-indicator-gapvar(--_thickness)
--slotted-progress-indicator-indicator-colorvar(--slotted-tone-accent-text)
--slotted-progress-indicator-percent0
--slotted-progress-indicator-positionabsolute
--slotted-progress-indicator-radiusvar(--slotted-radius-full, 9999px)
--slotted-progress-indicator-sizevar(--slotted-control-height-md, 34px)
--slotted-progress-indicator-stroke6
--slotted-progress-indicator-thicknessvar(--slotted-space-3, 0.375rem)
--slotted-progress-indicator-track-colorcolor-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

TokenDefault
--slotted-border-strongSet per scheme by the theme
--slotted-border-width-thin1px
--slotted-control-font-familyvar(--slotted-font-family-sans)
--slotted-control-font-size-lgcomfortable 14px · compact 13px · dense 12px
--slotted-control-font-size-mdcomfortable 13px · compact 12px · dense 12px
--slotted-control-font-size-smcomfortable 12px · compact 12px · dense 12px
--slotted-control-height-lgcomfortable 38px · compact 32px · dense 30px
--slotted-control-height-mdcomfortable 34px · compact 28px · dense 26px
--slotted-control-height-smcomfortable 30px · compact 26px · dense 24px
--slotted-duration-long320ms
--slotted-duration-loop1.1s
--slotted-duration-loop-slow1.6s
--slotted-duration-medium200ms
--slotted-duration-short120ms
--slotted-easing-emphasizedcubic-bezier(0.3, 0, 0, 1.3)
--slotted-easing-entercubic-bezier(0.05, 0.7, 0.1, 1)
--slotted-easing-exitcubic-bezier(0.3, 0, 0.8, 0.15)
--slotted-easing-standardcubic-bezier(0.2, 0, 0, 1)
--slotted-line-height-md1.5
--slotted-radius-full9999px
--slotted-radius-none0px
--slotted-space-20.25rem
--slotted-space-30.375rem
--slotted-space-40.5rem
--slotted-surfaceSet per scheme by the theme
--slotted-textSet per scheme by the theme
--slotted-text-mutedSet per scheme by the theme
--slotted-tone-accent-textSet per scheme by the theme
--slotted-tone-danger-textSet per scheme by the theme
--slotted-tone-info-textSet per scheme by the theme
--slotted-tone-success-textSet per scheme by the theme
--slotted-tone-warning-textSet per scheme by the theme
--slotted-z-index-sticky100