ProgressRing
A circular progress indicator in three sizes, exposed as a progressbar or, for a measurement, as a meter.
Import
import { ProgressRing } from '@nizivo/react/progress-ring';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/progress-ring.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. 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 { ProgressRing } from '@nizivo/react/progress-ring';
export function ProgressRingExample(): JSX.Element {
return (
<div>
<ProgressRing aria-label="Store setup" value={25} />
<ProgressRing aria-label="Monthly goal" meter value={75} tone="success" size="lg" />
<ProgressRing aria-label="Products imported" value={3} max={4} valueText="3 of 4" size="sm">
3/4
</ProgressRing>
</div>
);
}
Props
Server component Renders data-slot="progress-ring" with the class nz-progress-ring. Props: ProgressRingProps. Source: src/progress-ring/progress-ring.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
children | ReactNode | the percentage | The centre, shown to sighted users only (the ring's children are presentational). |
locale | string | 'en-US' | BCP 47 tag for the percentage. |
max | number | 100 | Must be above zero. |
meter | boolean | false | Exposes the ring as a |
render | RenderProp<ProgressRingState> | – | Name the ring with |
size | ProgressRingSize"sm""md""lg" | 'md' | |
tone | ProgressRingTone"brand""success""warning""critical""neutral" | 'brand' | |
valuerequired | number | – | Figma "Value" (25 / 50 / 75 / 100 there). Clamped to |
valueText | string | – | What assistive technology reads instead of the percentage. Set it whenever |
- Also takes every attribute of
<div>exceptrole;childrenis redeclared above. (Omit<ComponentPropsWithRef<"div">, "role">)
render takes an element, or, in client code, a function of the props and this state (ProgressRingState):
| Name | Type | Default | Description |
|---|---|---|---|
maxrequired | number | – | |
sizerequired | ProgressRingSize"sm""md""lg" | – | |
tonerequired | ProgressRingTone"brand""success""warning""critical""neutral" | – | |
valuerequired | number | – | The value clamped to |
Other exports
ProgressRingPropstypeimport type { ProgressRingProps } from '@nizivo/react/progress-ring'The props of
ProgressRing, listed above.ProgressRingSizetypeimport type { ProgressRingSize } from '@nizivo/react/progress-ring'48 / 72 / 96 px; Figma draws only 72.
type ProgressRingSize = "sm" | "md" | "lg"ProgressRingStatetypeimport type { ProgressRingState } from '@nizivo/react/progress-ring'The render state of
ProgressRing, listed above.ProgressRingTonetypeimport type { ProgressRingTone } from '@nizivo/react/progress-ring'type ProgressRingTone = "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-ring.nz-progress-ring | ProgressRingroot (takes render) |
|
progress-ring-fill.nz-progress-ring-fill | ProgressRinginner element (CSS only) | none |
progress-ring-label.nz-progress-ring-label | ProgressRinginner element (CSS only) | none |
progress-ring-track.nz-progress-ring-track | ProgressRinginner 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-ring-fill |
|
|
--nz-progress-ring-label-font | --nz-font-label-m-strong |
|
--nz-progress-ring-size |
|
|
--nz-progress-ring-track-bg | --nz-chart-track |
|
Layers: nz.components. Classes: .nz-progress-ring, .nz-progress-ring-fill, .nz-progress-ring-label, .nz-progress-ring-svg, .nz-progress-ring-track.
Tokens this stylesheet reads (10)
--nz-chart-critical, --nz-chart-neutral, --nz-chart-primary, --nz-chart-success, --nz-chart-track, --nz-chart-warning, --nz-duration-base, --nz-easing-standard, --nz-font-label-m-strong, --nz-text-primary
Accessibility
Nothing in this component takes focus or keyboard input.
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:13545 - Ghost masters: Figma node
751:388
ProgressBar
A native progress bar for a task or goal, determinate or indeterminate, with a visible label and value.
QuantityStepper
A whole-number quantity, such as a product page's or a cart line's, in Input's box between a minus and a plus button. The input is a native number input; the buttons step it for the pointer and are disabled at the ends of the range.