Progress Ring
A small visual indicator that communicates ongoing task execution.
import {ProgressRing} from "@qualcomm-ui/react/progress-ring"Overview
The progress ring can be in one of two states:
- indeterminate: the default state.
- determinate: assumed when the value prop is passed.
Indeterminate progress rings keep users informed that work is happening when timeframes are unknown.
Examples
Simple
For most use cases, you can use the simple ProgressRing component.
<ProgressRing />Composite
Build with the composite API for granular control. This API requires you to provide each subcomponent, but gives you full control over the structure and layout.
Value
When the value prop is set, the filled portion of the circle will represent the total percent relative to max and min. This is referred to as the "determinate" state.
<ProgressRing
size="lg"
value={value}
valueText={(api) => `${api.valuePercent}%`}
/>Value Text
Display the value text by passing a value to the valueText prop. The value text only shows when the size is lg or xl.
<ProgressRing
size="lg"
value={value}
valueText={(api) => `${api.valuePercent}%`}
/>Sizes
Use the size prop to change the size of the circle.
Thickness
Use the thickness prop to change the pixel width of the track and bar.
<ProgressRing className="py-2" size="lg" thickness={8} />Shortcuts
The ProgressRing.Circle component automatically renders the track and bar components when child. The following two examples are
<ProgressRing.Circle />Accessibility
- When the value is supplied, the component automatically provides the corresponding
aria-value*attributes to the element. - The progress element is automatically marked with
role="progressbar". - The label is automatically associated with the progress bar. If you omit the label property, the
aria-labelof the progress element defaults to the value when determinate, and "Loading" when indeterminate.
API
<ProgressRing>
The ProgressRing component extends the ProgressRing.Root with the following props:
| Prop | Type |
|---|---|
Props passed to the progress bar. | |
Props passed to the progress circle container. | |
Props passed to the progress circle. | |
Props passed to the error text. | |
Accessible label for the progress ring, rendered below the circle. | |
Props passed to the progress label. | |
Props passed to the progress track. | |
Value text Render Prop | |
Props passed to the value text. |
ProgressApi
This API is accessible in JSX via the <ProgressRing.Context> component:
<ProgressRing.Context>
{(api: ProgressApi) => {
return <>{/*...*/}</>
}}
</ProgressRing.Context>| Prop | Type |
|---|---|
Whether the progress bar is indeterminate | boolean |
The maximum value of the progress bar. | number |
The minimum value of the progress bar. | number |
Sets the value of the progress bar. | ( |
The computed state of the progress bar, based on the value. | | 'indeterminate' |
The current value of the progress bar. | number |
The current value of the progress bar as a percentage, computed from the min
and max values. | number |
booleannumbernumber(
value: number,
) => void
| 'indeterminate'
| 'complete'
| 'loading'
value.numbernumbermin
and max values.Composite API
<ProgressRing.Root>
<div>
element by default.| Prop | Type | Default |
|---|---|---|
The initial value of the progress when it is first rendered. Use when you do
not need to control the state of the progress. | number | |
The document's text/writing direction. | 'ltr' | 'rtl' | 'ltr' |
Governs the color of the progress circle. | | 'primary' | 'primary' |
The element ids that are associated with the progress. These will be
automatically generated if omitted. | Partial<{ | |
If true, the progress is marked as invalid. | boolean | |
Maximum value. | number | 100 |
Minimum value. | number | 0 |
Callback fired when the value changes. | ( | |
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement | |
Governs the height of the progress circle and track. | | 'xxs' | 'md' |
| string | ||
The value of the progress. If omitted, the component will render as an
indefinite progress bar. | number |
number'ltr' | 'rtl'
| 'primary'
| 'neutral'
Partial<{
errorText: string
hint: string
label: string
progress: string
}>
booleantrue, the progress is marked as invalid.numbernumber(
value: number | undefined,
) => void
| ReactElement
| ((
props: object,
) => ReactElement)
| 'xxs'
| 'xs'
| 'sm'
| 'md'
| 'lg'
| 'xl'
| number
| string
| number
The default value varies based on the size of the progress circle.
number| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__root' |
data-invalid | |
data-max | number |
data-part | 'root' |
data-scope | 'progress' |
data-size | | 'xxs' |
data-state | | 'indeterminate' |
data-value | number |
style |
className'qui-progress-ring__root'data-invaliddata-maxnumberdata-part'root'data-scope'progress'data-size| 'xxs'
| 'xs'
| 'sm'
| 'md'
| 'lg'
| 'xl'
| number
data-state| 'indeterminate'
| 'complete'
| 'loading'
data-valuenumberstyle<ProgressRing.Label>
<label> element by
default.| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be automatically generated for accessibility. | string |
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
string| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__label' |
data-part | 'label' |
data-scope | 'progress' |
className'qui-progress-ring__label'data-part'label'data-scope'progress'<ProgressRing.ValueText>
lg or
xl. Renders a <div> element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__value-text' |
data-invalid | |
data-part | 'value-text' |
data-scope | 'progress' |
hidden | boolean |
className'qui-progress-ring__value-text'data-invaliddata-part'value-text'data-scope'progress'hiddenboolean<ProgressRing.ErrorText>
<div> element by default.| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be automatically generated for accessibility. | string |
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
string| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__error-text' |
data-part | 'error-text' |
data-scope | 'progress' |
hidden | boolean |
className'qui-progress-ring__error-text'data-part'error-text'data-scope'progress'hiddenboolean<ProgressRing.CircleContainer>
<div> element
by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__circle-container' |
data-part | 'circle-container' |
data-scope | 'progress' |
className'qui-progress-ring__circle-container'data-part'circle-container'data-scope'progress'<ProgressRing.Circle>
<svg> element.| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be automatically generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__circle' |
data-emphasis | | 'primary' |
data-part | 'circle' |
data-scope | 'progress' |
data-size | | 'xxs' |
data-state | | 'indeterminate' |
style |
className'qui-progress-ring__circle'data-emphasis| 'primary'
| 'neutral'
data-part'circle'data-scope'progress'data-size| 'xxs'
| 'xs'
| 'sm'
| 'md'
| 'lg'
| 'xl'
| number
data-state| 'indeterminate'
| 'complete'
| 'loading'
style<ProgressRing.Track>
<circle> element.| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__track' |
data-part | 'circle-track' |
data-scope | 'progress' |
data-size | | 'xxs' |
data-state | | 'indeterminate' |
className'qui-progress-ring__track'data-part'circle-track'data-scope'progress'data-size| 'xxs'
| 'xs'
| 'sm'
| 'md'
| 'lg'
| 'xl'
| number
data-state| 'indeterminate'
| 'complete'
| 'loading'
<ProgressRing.Bar>
<circle> element.| Attribute / Property | Value |
|---|---|
className | 'qui-progress-ring__bar' |
data-emphasis | | 'primary' |
data-invalid | |
data-max | number |
data-part | 'circle-bar' |
data-scope | 'progress' |
data-size | | 'xxs' |
data-state | | 'indeterminate' |
style |
className'qui-progress-ring__bar'data-emphasis| 'primary'
| 'neutral'
data-invaliddata-maxnumberdata-part'circle-bar'data-scope'progress'data-size| 'xxs'
| 'xs'
| 'sm'
| 'md'
| 'lg'
| 'xl'
| number
data-state| 'indeterminate'
| 'complete'
| 'loading'
style