Components

Progress

Shows how far a task has got toward done, or that it is still running when the amount is unknown.

Usage

import {
  Progress,
  ProgressLabel,
  ProgressTrack,
  ProgressValue,
} from 'nyctoui/progress'

<Progress value={64}>
  <ProgressLabel>Uploading</ProgressLabel>
  <ProgressValue />
  <ProgressTrack />
</Progress>

The label and value share the first row; the track spans the full width below them, at the same 4px as the Slider track. Use Progress for a task that moves toward done, and Meter for a quantity that isn’t heading anywhere, such as storage used.

Good for

  • A file upload or an import, with a percentage.
  • A video or podcast player’s playback bar.
  • Steps finished in an onboarding checklist, such as “3 of 5 done”.
  • A long export running in the background, before its size is known.

Examples

Determinate

ProgressValue shows a percentage of min to max unless the root has a format. The indicator eases to each new value.

Indeterminate

Pass value={null} while the amount of work is unknown. A short bar sweeps across the track; with reduced motion it fills the track and fades in and out instead.

Custom value

Pass a function to ProgressValue to write the value your own way, and getValueLabel so screen readers hear the same thing.

Media player

The demo at the top of the page. The bar shows playback position in seconds against the track’s length, updated four times a second; the easing on the indicator smooths the steps. There is no visible label, so the root takes an aria-label. The bar is display only: to let people seek, use a Slider instead.

Best practices

Do
  • Show the value when you know it, and use the indeterminate state only while you don’t.
  • Give the bar a ProgressLabel that says what’s running, even if it’s visually hidden.
  • Use getValueLabel when a percentage would mislead, such as “3 of 5 files”.
Don’t
  • Show a progress bar for something that finishes at once.
  • Stack several bars for one task. Show one bar for the whole job.
  • Use progress for a level like storage used. That’s a meter.

API reference

Progress

Wraps ui-sdk’s Progress and takes its props, including format, locale and getValueLabel. Sets data-progressing, data-complete or data-indeterminate on every part.

PropTypeDefault
value
Current value. null makes the bar indeterminate.
number | null—
min
Value at an empty bar.
number0
max
Value at a full bar.
number100
format
How the value is written in ProgressValue and for screen readers.
Intl.NumberFormatOptions—
getValueLabel
What a screen reader announces for the value.
(value: number | null, details: { formatted, percent, min, max }) => string—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

ProgressLabel

A <span> in the first row that labels the bar.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

ProgressValue

A <span> at the end of the first row showing the formatted value.

PropTypeDefault
children
Write the value yourself instead of the default.
(state: { value, text, … }) => ReactNode—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

ProgressTrack

The full-width track, with the indicator inside.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—