FeedbackReact
Shows the stages of one task on a single bar, such as uploading, processing and publishing a video.
Rendered by React 19.3.1
Installation
npm i @hamur/reactNot on npm yet. The package goes out under the chosen name.
Anatomy
Import the component and assemble its parts:
<ProgressGroup.Root>
<ProgressGroup.Label />
<ProgressGroup.Value />
<ProgressGroup.Track>
<ProgressGroup.Indicator />
</ProgressGroup.Track>
<ProgressGroup.Item>
<ProgressGroup.ItemLabel />
<ProgressGroup.ItemValue />
</ProgressGroup.Item>
</ProgressGroup.Root>Examples
Indeterminate
A backup whose amounts are unknown until scanning finishes; the track animates instead.
API reference
10 props across 8 parts, in React syntax. className, style, render are listed once, under Shared props.
IndicatorProgressGroup.Indicator
Draws the segment of one value along the track; no size while indeterminate. Renders a <div>.
| Prop | Type | Default |
|---|---|---|
indexrequiredThe position in value of the amount this segment draws. | number | — |
ItemProgressGroup.Item
The progress bar of one value, named by its item label: the group's legend entry. Renders a <div>.
| Prop | Type | Default |
|---|---|---|
aria-valuetextA string value that provides a user-friendly name for aria-valuenow, the current value of | string | — |
indexrequiredThe position in value of the amount this progress bar reads. | number | — |
ItemLabelProgressGroup.ItemLabel
An accessible label for the progress bar. Renders a <span>.
| Data attribute | Description |
|---|---|
data-complete | Present when the progress has completed. |
data-indeterminate | Present when the progress is in indeterminate state. |
data-progressing | Present while the progress is progressing. |
ItemValueProgressGroup.ItemValue
A text element displaying the current value. Renders a <span>.
| Prop | Type | Default |
|---|---|---|
children | ((formattedValue: string | null, value: number | null) => React.ReactNode) | null | — |
| Data attribute | Description |
|---|---|
data-complete | Present when the progress has completed. |
data-indeterminate | Present when the progress is in indeterminate state. |
data-progressing | Present while the progress is progressing. |
LabelProgressGroup.Label
An accessible label for the group. Renders a <span>.
RootProgressGroup.Root
Groups the progress bars of the parts of one task, named by its label. Renders a <div>.
| Prop | Type | Default |
|---|---|---|
formatOptions to format each value and the total. | Intl.NumberFormatOptions | — |
getAriaValueTextA function that returns the aria-valuetext of each item, from its formatted value, its entry | ProgressGroupGetAriaValueText | — |
localeThe locale used by Intl.NumberFormat when formatting the values. | Intl.LocalesArgument | — |
maxThe amount the task completes at. | number | 100 |
valuerequiredThe amounts, in segment order. | readonly number[] | null | — |
TrackProgressGroup.Track
Contains the indicators and represents the whole capacity. Renders a <div>.
ValueProgressGroup.Value
A text element displaying the total of the values. Renders a <span>.
| Prop | Type | Default |
|---|---|---|
children | ((formattedValue: string | null, value: number | null) => React.ReactNode) | null | — |
Shared props
Every part that renders an element takes these.
| Prop | Type |
|---|---|
classNameCSS class applied to the element, or a function that
returns a class based on the component's state. | string | ((state: State) => string | undefined) |
styleStyle applied to the element, or a function that
returns a style object based on the component's state. | React.CSSProperties | ((state: State) => React.CSSProperties | undefined) |
renderAllows you to replace the component's HTML element
with a different tag, or compose it with another component. | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, State> |
Keyboard and accessibility
Keyboard
ProgressGroup takes no focus and has no keys of its own.
Accessibility
| Part | Sets | So that |
|---|---|---|
| Root | role="group", aria-labelledby to Label | the stages are read as one named task |
| Item | role="progressbar", aria-valuemin="0", aria-valuemax, aria-valuenow (left out while the value is unknown) | a screen reader reads how far each stage is, or that it is in progress |
| Item | aria-valuetext from format, getAriaValueText or aria-valuetext, aria-labelledby to ItemLabel | each stage is read with its name and as written, such as "40%" |
| Value | the formatted total as text | the progress of the whole task is read in place |
| ItemValue | aria-hidden="true" | the visible number is not read twice |
Focus order
- ProgressGroup is not focusable; focus passes over it.