Progress

Slant / Controls

Progress bars with tones, determinate or indeterminate.

Demo

Usage

@tuttn/slant
import { Progress } from '@tuttn/slant'

<Progress value={38} label="Upload" />
<Progress value={100} label="Upload" tone="success" />
<Progress value={61} max={100} label="Retrying" tone="danger" />

// Out-of-range values are clamped: this one reads as 100 and fills the bar.
<Progress value={140} label="Upload" />

// No value: indeterminate. A block of slanted pixels sweeps along the bar
// until you pass one.
<Progress label="Connecting" />
<Progress value={connected ? 100 : undefined} label="Connecting" />

Props

PropTypeDefaultDescription
valuenumber—How far along, from 0 to `max`. A value outside that range is clamped to it. Omit it while the amount is unknown: the bar is indeterminate, and a block of slanted pixels sweeps from the inline start to the end.
maxnumber100The value that fills the bar. Ignored while indeterminate.
labelstring—The progressbar's accessible name, e.g. "Upload".
toneTone'accent'The fill colour.
…restHTMLAttributes<HTMLDivElement>—className, style and other attributes go on the progressbar element, which also takes the ref.

Progress takes its value from you; it has no state of its own. A value below 0 or above max is clamped, both in the fill and in aria-valuenow.

Leave value out while the amount is unknown. The bar is then indeterminate: it carries data-indeterminate and no aria-valuenow (nor a min or max), so screen readers report it as busy rather than as 0%, and a block of four slanted pixels sweeps from the inline start to the end. With reduced motion the block rests at the start as a static partial fill, its pixels fading toward the tail, so it still reads as working. Pass a value as soon as you have one.

A progressbar takes no focus and has no keyboard behaviour; its label is its name. Under dir="rtl" the fill grows from the right and the indeterminate block sweeps right to left.

For a value that measures something rather than tracks a task (storage used, quota), use a Meter, which also offers the pixel-row variant.