Skip to the content
human-kit design
58 — Feedback

Progress

How far a task that takes time has gone, or that it is still going.

Exporting records

Installation

pnpm dlx @human-kit/design add progress
npx @human-kit/design add progress
yarn dlx @human-kit/design add progress
bunx @human-kit/design add progress

The command copies the files to src/lib/components/ui/progress. It also installs the packages that the files import.

Usage

<script lang="ts">
	import * as Progress from '$lib/components/ui/progress';
</script>

<Progress.Root label="Exporting records" value={62} />

Examples

A value in its unit

By default the value reads as a percent of the range. Give format the options of Intl.NumberFormat to show the value itself, as "340 MB", and getValueText to tell a screen reader the whole of it.

Storage used

Guidelines

  • Use it for a task that takes more than a second or two and whose end is known: an export, an upload, a sync.
  • Pass value={null} while the end is not known yet, and a number as soon as it is. A bar that only moves says nothing of how long is left.
  • Say in label what is in progress, as a verb: "Exporting records", not "Progress".
  • Use size="sm" inside a row or a card, where the bar is one detail among others.
  • For a short wait inside a button, use its pending state instead of a bar beside it.

Accessibility

  • It renders a role="progressbar" with aria-valuemin, aria-valuemax and aria-valuenow, and the formatted value in aria-valuetext.
  • label names the bar. Without one, give it an aria-label.
  • While the value is null the bar has no aria-valuenow: a number for a task of no known end would be wrong.
  • Where motion is reduced, the bar of no known end stands still: the whole track turns a faint primary in place of the moving stretch.
  • A screen reader does not hear every change. Announce the end of the task in a toast or in the page.

API reference

PropTypeDefault
valuenumber | null

How far the task is, between min and max. null while its end is not known.

—
minnumber

The value at the start of the task.

0
maxnumber

The value at the end of the task.

100
labelstring

What is in progress, over the bar.

—
showValueboolean

Shows the value at the end of the label's line, while it is known.

true
size'sm' | 'default'

The thickness of the track: 4px or 6px.

'default'
formatIntl.NumberFormatOptions

How the value is written. Without it, as a percent of the range.

—
getValueText(formattedValue: string, value: number | null) => string

The text a screen reader gets for the value.

—
aria-valuetextstring

The text a screen reader gets for the value. It wins over getValueText.

—
elementHTMLDivElement | null

The rendered element. Bindable.

—
contextProgressContext

The state of the bar: percent, status and formattedValue, for a shape of your own. Bindable.

—

Plus every attribute of a <div>, on the bar.