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.

Indeterminate
Determinate
64%
Optional hint
<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.

Label
64%
Optional hint
<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.

Determinate
64%
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

sm
md
lg
<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:

  • invalid
  • errorText (or the Progress.ErrorText component when using the composite API)

The error text will only render when invalid is true.

Loading Module
25%
Network disconnected, please try again
<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-label of 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.

PropType
Props passed to the progress bar.
Error text rendered when invalid is true.
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.
Props passed to the value text.
Description
Props passed to the progress bar.
Description
Error text rendered when invalid is true.
Description
Props passed to the error text element.
Description
Optional hint text rendered below the progress bar.
Description
Props passed to the hint element.
Description
The progress label.
Description
Props passed to the progress label.
Description
Props passed to the progress track.
Description
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

PropType
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.
    (
    value: number,
    ) => void
    The computed state of the progress bar, based on the value.
    | 'indeterminate'
    | 'complete'
    | 'loading'
    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
    Type
    boolean
    Description
    Whether the progress bar is indeterminate
    Type
    number
    Description
    The maximum value of the progress bar.
    Type
    number
    Description
    The minimum value of the progress bar.
    Type
    (
    value: number,
    ) => void
    Description
    Sets the value of the progress bar.
      Type
      | 'indeterminate'
      | 'complete'
      | 'loading'
      Description
      The computed state of the progress bar, based on the value.
      Type
      number
      Description
      The current value of the progress bar.
      Type
      number
      Description
      The current value of the progress bar as a percentage, computed from the min and max values.

      Composite API

      <Progress.Root>

      Root container for a progress indicator. Renders a <div> element by default.
      PropTypeDefault
      React children prop.
      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'
      | 'neutral'
      'primary'
      
      The element ids that are associated with the progress. These will be automatically generated if omitted.
      Partial<{
      errorText: string
      hint: string
      label: string
      progress: string
      }>
      If true, the progress is marked as invalid.
      boolean
      Governs the placement of the label and value text relative to the progress bar.
      • top: the label and value text are positioned above the progress bar.
      • side: the label and value text are positioned on the same horizontal axis as the progress bar, to the left and right, respectively.
      'top' | 'side'
      'top'
      
      Maximum value.
      number
      100
      
      Minimum value.
      number
      0
      
      Callback fired when the value changes.
        (
        value: number | undefined,
        ) => void
        Allows you to replace the component's HTML element with a different tag or component. Learn more
        | ReactElement
        | ((
        props: object,
        ) => ReactElement)
        Governs the height of the progress bar and track.
        | 'sm'
        | 'md'
        | 'lg'
        'md'
        
        The value of the progress. If omitted, the component will render as an indefinite progress bar.
        number
        Description
        React children prop.
        Type
        number
        Description
        The initial value of the progress when it is first rendered. Use when you do not need to control the state of the progress.
        Type
        'ltr' | 'rtl'
        Description
        The document's text/writing direction.
        Type
        | 'primary'
        | 'neutral'
        Description
        Governs the color of the progress bar.
        Type
        Partial<{
        errorText: string
        hint: string
        label: string
        progress: string
        }>
        Description
        The element ids that are associated with the progress. These will be automatically generated if omitted.
        Type
        boolean
        Description
        If true, the progress is marked as invalid.
        Type
        'top' | 'side'
        Description
        Governs the placement of the label and value text relative to the progress bar.
        • top: the label and value text are positioned above the progress bar.
        • side: the label and value text are positioned on the same horizontal axis as the progress bar, to the left and right, respectively.
        Type
        number
        Description
        Maximum value.
        Type
        number
        Description
        Minimum value.
        Type
        (
        value: number | undefined,
        ) => void
        Description
        Callback fired when the value changes.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more
          Type
          | 'sm'
          | 'md'
          | 'lg'
          Description
          Governs the height of the progress bar and track.
          Type
          number
          Description
          The value of the progress. If omitted, the component will render as an indefinite progress bar.

          <Progress.Label>

          Label for the progress indicator. Renders a <div> element by default.
          PropType
          React children prop.
          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
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          string
          Description
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more

          <Progress.ErrorText>

          Error text displayed when the progress is in an invalid state. Renders a styled error text element.
          PropType
          React children prop.
          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
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          string
          Description
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more

          <Progress.Hint>

          PropType
          React children prop.
          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
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          string
          Description
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more

          <Progress.ValueText>

          Text that displays the progress value. Renders a <div> element by default.
          PropType
          React children prop.
          Allows you to replace the component's HTML element with a different tag or component. Learn more
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more

          <Progress.Track>

          Container for the progress bar. Renders a <div> element by default.
          PropTypeDefault
          React children prop.
          <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
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          string
          Description
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more

          <Progress.Bar>

          Visual indicator that shows progress completion. Renders a <div> element by default.
          PropType
          React children prop.
          Allows you to replace the component's HTML element with a different tag or component. Learn more
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more