@biem/ui

Progress

A bar that shows users how far a task has come.

A progress bar shows users how far a task has come. Its indicator fills the track as the value moves from the minimum to the maximum, and a label names the task for users and for assistive technology.

x

Usage

progress-default.tsx
import { Progress } from "@biem/ui/components/ui/progress";

export function ProgressDefault() {
	return (
		<div className="w-full max-w-sm">
			<Progress value={60} aria-label="Inventory count"/>
		</div>
	);
}

Examples

With Label

Users need to know which task a progress bar measures before its value means anything to them. Placed inside the progress bar, ProgressLabel names that task on screen and gives assistive technology the same name.

Inventory count
x

With Value

A bar alone leaves users estimating how much of a task remains. With ProgressValue, the value appears as text as well, by default as a percentage of the range, while assistive technology already receives the same figure from the progress bar itself.

Inventory count
x

Custom Range

Many tasks are counted in units of their own, such as the positions of an order or the shelves of a store. Through min and max the progress bar adopts that range, so the application passes the count as it is and the value still appears as a percentage of the whole.

Delivery check-in
x

Custom Value Text

Sometimes a percentage hides the figure users actually work with, such as the number of items still open. A function as the children of ProgressValue then shows the value in the words of the task, while assistive technology keeps announcing the formatted value unless getAriaValueText provides the same words.

Delivery check-in
x

Formatted Value

Progress toward a budget or a revenue goal is measured in money rather than in percent. With format, the value appears as a currency amount or in any other unit the task requires, and locale decides how it is written, so users read and assistive technology announces the same figure.

Weekly sales target
x

Info

Some processes run in the background and ask nothing of users, such as an import of new product data. Set to "info", variant presents such progress as information only, so users can follow it without feeling asked to act.

Syncing inventory
x

Success

A finished task that went as planned, such as a price update that reached every store, lets users move on with confidence. With variant set to "success", the progress bar confirms that outcome, so users need not check the result again.

Delivery received
x

Warning

Progress can fall behind what a schedule allows, for example a replenishment that must be finished before the store opens. Once variant is set to "warning", the progress bar asks for attention while the task continues, so users can step in before the delay matters.

Count due today
x

Destructive

An interrupted upload leaves work that users have to take up again. With variant set to "destructive", the progress bar marks the task as failed, and since the status shows only through color, the label names the failure in words as well.

Transfer failed
x

Complete

A task that has ended should read as ended, so users can turn to the next one. As soon as value reaches max, the progress bar is complete, and assistive technology announces the full amount instead of a share of it.

Inventory count
x

Controlled

Most progress follows work that happens elsewhere in the interface, such as items that users confirm one at a time. The application holds value in its own state and passes every new count to the progress bar, which keeps pace with each step users complete.

Delivery check-in
x

API Reference

Progress

Propvariant
Type"default" | "destructive" | "info" | "success" | "warning"
Default"default"
DescriptionSets the status of the progress bar and colors its indicator to match.
Propvalue
Typenumber | null
Default–
DescriptionSets the current value. It is required. With null, the progress bar is indeterminate, which tells assistive technology that the amount of work is unknown.
Propmin
Typenumber
Default0
DescriptionSets the value at which the indicator is empty.
Propmax
Typenumber
Default100
DescriptionSets the value at which the indicator fills the track and the progress bar is complete.
Propformat
TypeIntl.NumberFormatOptions
Default–
DescriptionSets the options that format the value. ProgressValue shows the formatted value, and assistive technology announces it. Without it, the value is formatted as a percentage of the range from min to max.
Proplocale
TypeIntl.LocalesArgument
Default–
DescriptionSets the locale in which the value is formatted. Without it, the locale of the runtime is used.
PropgetAriaValueText
Type(formattedValue: string, value: number | null) => string
Default–
DescriptionReturns the text that assistive technology announces for the current value. It receives the formatted value and the value. Without it, assistive technology announces the formatted value.
Proparia-valuetext
Typestring
Default–
DescriptionSets the text that assistive technology announces in place of the formatted value. It takes precedence over getAriaValueText.
Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the progress bar with another component.

ProgressLabel

Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the label with another component.

ProgressValue

Propchildren
Type(formattedValue: string | null, value: number | null) => ReactNode
Default–
DescriptionReturns the content that the part shows. The function receives the formatted value and the value. Without it, the part shows the formatted value.
Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the value with another component.

ProgressTrack

ProgressTrack is the bar that the indicator fills. Progress renders it itself, after its children.

Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the track with another component.

ProgressIndicator

ProgressIndicator fills the track up to the current value. Progress renders it itself, inside ProgressTrack.

Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the indicator with another component.