Progress
Progress bars provide clear visual feedback about task completion or loading states, helping users understand system status and perceived remaining time.
import {Progress} from "@qualcomm-ui/react/progress"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 bars keep users informed that work is happening when timeframes are unknown.
Examples
Simple
The simple API provides a standalone component with built-in layout.
<Progress className="w-64" label="Indeterminate" />
<Progress
hint="Optional hint"
label="Determinate"
value={64}
valueText="64%"
/>
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.
<Progress.Root className="w-64" value={64}>
<Progress.Label>Label</Progress.Label>
<Progress.Context>
{(api) => (
<Progress.ValueText>{`${api.valuePercent}%`}</Progress.ValueText>
)}
</Progress.Context>
<Progress.ValueText />
<Progress.Track />
<Progress.Hint>Optional hint</Progress.Hint>
</Progress.Root>
Label Orientation
Use the labelOrientation property to change the positioning of the label and value text relative to the progress bar.
import type {ReactElement} from "react"
import {Progress} from "@qualcomm-ui/react/progress"
export function ProgressLabelOrientationDemo(): ReactElement {
return (
<div className="flex flex-col gap-6">
<Progress
className="w-96"
label="Determinate"
labelOrientation="side"
value={64}
valueText="64%"
/>
</div>
)
}Sizes
<Progress label="sm" size="sm" value={value} />
<Progress label="md" size="md" value={value} />
<Progress label="lg" size="lg" value={value} />
Emphasis (Color)
<Progress emphasis="primary" />
<Progress emphasis="neutral" />
Error Text
Error messages are displayed using two props:
The error text will only render when invalid is true.
<Progress
className="w-64"
defaultValue={25}
errorText="Network disconnected, please try again"
invalid
label="Loading Module"
valueText={({valuePercent}) => `${valuePercent}%`}
/>
Shortcuts
Track and Bar
The Progress.Track automatically renders a Progress.Bar when no children as passed to it.
<Progress.Track />is equivalent to
<Progress.Track>
<Progress.Bar />
</Progress.Track>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
<Progress>
The Progress component supports all props from Progress.Root, plus the additional props listed below.
| Prop | Type |
|---|---|
Props passed to the progress bar. | |
Props passed to the error text element. | |
Optional hint text rendered below the progress bar. | |
Props passed to the hint element. | |
The progress label. | |
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 <Progress.Context> component:
<Progress.Context>
{(api: ProgressApi) => {
return <>{/*...*/}</>
}}
</Progress.Context>Learn more about this pattern: Render Props
| 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
<Progress.Root>
| 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 bar. | | '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 | |
Governs the placement of the label and value text relative to
the progress bar. | 'top' | 'side' | 'top' |
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 bar and track. | | 'sm' | 'md' |
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.'top' | 'side'
numbernumber(
value: number | undefined,
) => void
| ReactElement
| ((
props: object,
) => ReactElement)
| 'sm'
| 'md'
| 'lg'
number<Progress.Label>
<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)
<Progress.ErrorText>
| 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)
<Progress.Hint>
| 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)
<Progress.ValueText>
<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)
<Progress.Track>
<div> element by default.| Prop | Type | Default |
|---|---|---|
<ProgressBar /> | ||
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)
<Progress.Bar>
<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)
<div>element by default.