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 bars support three sizes: sm, md, and lg.
<Progress label="sm" size="sm" value={value} />
<Progress label="md" size="md" value={value} />
<Progress label="lg" size="lg" value={value} />
Emphasis (Color)
Set the color of the progress bar using the emphasis property. The available options are primary and neutral.
<Progress emphasis="primary" />
<Progress emphasis="neutral" />
Disabled
Use the disabled prop to indicate that the progress indicator is inactive.
<Progress className="w-64" disabled label="Indeterminate" />
<Progress
className="w-64"
disabled
label="Determinate"
value={64}
valueText="64%"
/>
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.
Explorer
API
<Progress>
The Progress component supports all props from Progress.Root, plus the additional props listed below.
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
booleannumbernumber(
value: number,
) => void
| 'indeterminate'
| 'complete'
| 'loading'
value.numbernumbermin
and max values.Composite API
<Progress.Root>
number'ltr' | 'rtl'
booleantrue, the progress is disabled.| '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'
numberclassName'qui-progress__root'data-disableddata-invaliddata-label-orientation'top' | 'side'
data-maxnumberdata-progress-part'root'data-size| 'sm'
| 'md'
| 'lg'
data-state| 'indeterminate'
| 'complete'
| 'loading'
data-valuenumberstyle<Progress.Label>
<div> element by default.string| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-progress__label'data-progress-part'label'<Progress.ErrorText>
string| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-progress__error-text'data-progress-part'error-text'hiddenboolean<Progress.Hint>
string| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-progress__hint'data-progress-part'hint'hiddenboolean<Progress.ValueText>
<div> element by default.| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-progress__value-text'data-invaliddata-progress-part'value-text'<Progress.Track>
<div> element by default.string| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-progress__track'data-disableddata-progress-part'track'data-size| 'sm'
| 'md'
| 'lg'
data-state| 'indeterminate'
| 'complete'
| 'loading'
<Progress.Bar>
<div> element by
default.| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-progress__bar'data-disableddata-emphasis| 'primary'
| 'neutral'
data-invaliddata-maxnumberdata-progress-part'bar'data-size| 'sm'
| 'md'
| 'lg'
data-state| 'indeterminate'
| 'complete'
| 'loading'
style
<div>element by default.