ProgressBar
A native progress bar for a task or goal, determinate or indeterminate, with a visible label and value.
Import
import { ProgressBar } from '@nizivo/react/progress-bar';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/progress-bar.css';Static or interactive
Server. It ships no client JavaScript when a Server Component renders it, in every Next.js build
mode; its code is bundled only when a client component (a 'use client' file) imports it. The
indeterminate bar is a CSS animation. How to choose.
In a client app (a Vite or React Router single-page app, or a 'use client' file) it is an ordinary React component: event handlers, refs and state work as usual. In a client app.
Examples
Basic
import type { JSX } from 'react';
import { ProgressBar } from '@nizivo/react/progress-bar';
export function ProgressBarExample(): JSX.Element {
return (
<div>
<ProgressBar label="Monthly goal" value={68} />
<ProgressBar label="Setup guide" value={3} max={5} valueText="3 of 5 steps" tone="success" />
<ProgressBar label="Uploading product photos" indeterminate />
<ProgressBar aria-label="Import" value={40} showValue={false} tone="neutral" />
</div>
);
}
Props
Server component Renders data-slot="progress-bar" with the class nz-progress-bar. Props: ProgressBarProps. Source: src/progress-bar/progress-bar.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
indeterminate | boolean | false | Work is under way but its amount is unknown: the bar has no value. |
label | ReactNode | – | The visible name. Without it, name the bar with |
locale | string | 'en-US' | BCP 47 tag for the percentage. |
max | number | 100 | Must be above zero. |
render | RenderProp<ProgressBarState> | – | Composition of the root; the native |
showValue | boolean | true | Shows the value as a percentage beside the label (hidden from assistive technology, which reads the bar itself). |
tone | ProgressBarTone"brand""success""warning""critical""neutral" | 'brand' | |
value | number | 0 | Clamped to |
valueText | string | – | Replaces the shown percentage and is read instead of it, for example "3 of 5 steps". |
- Also takes every attribute of
<div>exceptchildren. (Omit<ComponentPropsWithRef<"div">, "children">)
render takes an element, or, in client code, a function of the props and this state (ProgressBarState):
| Name | Type | Default | Description |
|---|---|---|---|
indeterminaterequired | boolean | – | |
maxrequired | number | – | |
tonerequired | ProgressBarTone"brand""success""warning""critical""neutral" | – | |
valuerequired | number | null | – | The clamped value, or |
Other exports
ProgressBarPropstypeimport type { ProgressBarProps } from '@nizivo/react/progress-bar'The props of
ProgressBar, listed above.ProgressBarStatetypeimport type { ProgressBarState } from '@nizivo/react/progress-bar'The render state of
ProgressBar, listed above.ProgressBarTonetypeimport type { ProgressBarTone } from '@nizivo/react/progress-bar'Figma "Tone" (Brand, Warning, Critical) plus
successandneutral.type ProgressBarTone = "brand" | "success" | "warning" | "critical" | "neutral"
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
progress-bar.nz-progress-bar | ProgressBarroot (takes render) |
|
progress-bar-header.nz-progress-bar-header | ProgressBarinner element (CSS only) | none |
progress-bar-label.nz-progress-bar-label | ProgressBarinner element (CSS only) | none |
progress-bar-track.nz-progress-bar-track | ProgressBarinner element (CSS only); forced colours: fill on ::-webkit-progress-value, fill on ::-moz-progress-bar | none |
progress-bar-value.nz-progress-bar-value | ProgressBarinner element (CSS only) | none |
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
| Hook | Default | Read as |
|---|---|---|
--nz-progress-bar-fill |
|
|
--nz-progress-bar-gap | --nz-space-2 |
|
--nz-progress-bar-height | --nz-space-2 |
|
--nz-progress-bar-label-font | --nz-font-label-m |
|
--nz-progress-bar-radius | --nz-radius-full |
|
--nz-progress-bar-track-bg | --nz-chart-track |
|
Layers: nz.components. Classes: .nz-progress-bar, .nz-progress-bar-header, .nz-progress-bar-label, .nz-progress-bar-track, .nz-progress-bar-value.
Tokens this stylesheet reads (16)
--nz-chart-critical, --nz-chart-neutral, --nz-chart-primary, --nz-chart-success, --nz-chart-track, --nz-chart-warning, --nz-duration-base, --nz-duration-pulse, --nz-easing-standard, --nz-font-label-m, --nz-font-numeric-m, --nz-radius-full, --nz-space-2, --nz-space-3, --nz-text-primary, --nz-text-secondary
Accessibility
Nothing in this component takes focus or keyboard input.
In forced-colours mode these states keep a visible system colour: progress-bar-track::-webkit-progress-value (fill), progress-bar-track::-moz-progress-bar (fill).
Keyboard
None.
Figma
Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.
- Canonical: Figma node
7275:13526 - Ghost masters: Figma node
751:367
Popover
A small dialog anchored to its trigger, for status, quick settings and filters. It has a title, a description, any controls, and a close button; Escape or a press outside closes it, and focus returns to the trigger.
ProgressRing
A circular progress indicator in three sizes, exposed as a progressbar or, for a measurement, as a meter.