FeedbackReact
Displays the status of a task that takes a long time, such as an upload or an export.
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:
<Progress.Root>
<Progress.Label />
<Progress.Value />
<Progress.Track>
<Progress.Indicator />
</Progress.Track>
</Progress.Root>Examples
The demo at the top is the one example this component has so far.
API reference
8 props across 5 parts, in React syntax. className, style, render are listed once, under Shared props.
IndicatorProgress.Indicator
Visualizes the completion status of the task. Renders a <div>.
| 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. |
LabelProgress.Label
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. |
RootProgress.Root
Groups all parts of the progress bar and provides the task completion status to screen readers. Renders a <div>.
| Prop | Type | Default |
|---|---|---|
valuerequiredThe current value. | number | null | — |
aria-valuetextA string value that provides a user-friendly name for aria-valuenow, the current value of the progress bar. | string | — |
getAriaValueTextAccepts a function which returns a string value that provides a human-readable text alternative for the current value of the progress bar. | ((formattedValue: string, value: number | null) => string) | — |
localeThe locale used by Intl.NumberFormat when formatting the value. | Intl.LocalesArgument | — |
minThe minimum value. | number | 0 |
maxThe maximum value. | number | 100 |
formatOptions to format the value. | Intl.NumberFormatOptions | — |
| 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. |
TrackProgress.Track
Contains the progress bar indicator. Renders a <div>.
| 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. |
ValueProgress.Value
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. |
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
Progress takes no focus and has no keys of its own.
Accessibility
| Part | Sets | So that |
|---|---|---|
| Root | role="progressbar", aria-valuemin, aria-valuemax, aria-valuenow (left out while the value is unknown) | a screen reader reads how far the task is, or that it is in progress |
| Root | aria-valuetext from format, getAriaValueText or aria-valuetext | the value is read as written, such as "40%" |
| Root | aria-labelledby to Label | the bar is read with its name |
| Value | aria-hidden="true" | the visible number is not read twice |
Focus order
- Progress is not focusable; focus passes over it.