progress

Export data30%
import { progress } from '@markless/ui';export default function ProgressBasic() @{	<progress.root class="bar" value={30}>		<span class="bar-head">			<progress.label>Export data</progress.label>			<progress.valuelabel class="bar-value" />		</span>		<progress.track class="bar-track">			<progress.indicator class="bar-fill" />		</progress.track>	</progress.root>;}

progress is a progress bar. Use it to show how far along a task is, such as an export or an upload.

import { progress } from '@markless/ui';

export default function Export() @{
	<progress.root value={30}>
		<progress.label>Export data</progress.label>
		<progress.valuelabel />
		<progress.track>
			<progress.indicator />
		</progress.track>
	</progress.root>
}

The root writes role="progressbar", with aria-valuemin, aria-valuemax, aria-valuenow and aria-valuetext. progress.label gives the bar its name.

Anatomy

progress anatomy
Anatomy perspectiveFlat
Layers
Making progress65%
progress.root

The progress bar itself; the label, track and indicator go inside it.

  • progress.root holds the value and the range.
  • progress.label is a <span> that names the bar.
  • progress.valuelabel is a <span> that shows the value as text. Left empty, it shows a percentage.
  • progress.track is the full length of the range.
  • progress.indicator is the filled part. It sits inside the track.

Every part writes the same four attributes:

Attribute Value
ui-progress loading, complete, or indeterminate when the amount is unknown.
ui-value The current value. It is missing while the amount is unknown.
ui-min The bottom of the range.
ui-max The top of the range.

How the fill moves

progress.indicator writes its own style, a transform: translateX(...). At 30 out of 100 it is translateX(-70%). So the indicator is as wide as the track, and it slides in from the left.

Give the track overflow: hidden. Without that rule, the part of the indicator that slid out still shows to the left of the bar.

.track {
	overflow: hidden;
}

.indicator {
	height: 100%;
	background: currentColor;
}

A value past max draws a full bar, and a value below min draws an empty one. aria-valuenow reports the clamped value. ui-value keeps the number you passed, such as 150.

An unknown amount

Leave value out, or pass null, when you do not know how far along the task is. The bar then reports no current value. That is not the same as zero to a screen reader. Use [ui-progress='indeterminate'] to draw a moving stripe or a pulse.

Your own wording

Text you write inside progress.valuelabel replaces the percentage. The bar also reports that text as aria-valuetext, so a screen reader reads your words.

<progress.valuelabel>30 of 100 rows</progress.valuelabel>

Props on progress.root

Prop Type What it does
value number | null How far along the task is. Omit it, or pass null, for an unknown amount.
min number The bottom of the range. The default is 0.
max number The top of the range. The default is 100.

The root passes anything a <div> accepts to its element. A bar with no progress.label has no name. Give it an aria-label instead.