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.

0%
<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.

0%
<ProgressRing
  size="lg"
  value={value}
  valueText={(api) => `${api.valuePercent}%`}
/>

Sizes

Use the size prop to change the size of the circle.

xxs
xs
sm
md
lg
0%
xl
0%

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-label of 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:

A circular progress indicator that displays progress as a ring with optional value text and labels.
PropType
Props passed to the progress bar.
Props passed to the progress circle container.
Props passed to the progress circle.
Error text rendered below the progress ring when invalid is true.
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.
Props passed to the value text.
Description
Props passed to the progress bar.
Description
Props passed to the progress circle container.
Description
Props passed to the progress circle.
Description
Error text rendered below the progress ring when invalid is true.
Description
Props passed to the error text.
Description
Accessible label for the progress ring, rendered below the circle.
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 <ProgressRing.Context> component:

<ProgressRing.Context>
  {(api: ProgressApi) => {
    return <>{/*...*/}</>
  }}
</ProgressRing.Context>
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

      <ProgressRing.Root>

      The root container element for the progress ring component. 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 circle.
      | '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
      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 circle and track.
        | 'xxs'
        | 'xs'
        | 'sm'
        | 'md'
        | 'lg'
        | 'xl'
        | number
        'md'
        
        The thickness of the progress ring in pixels. If supplied as a number, it will be used as the pixel value.

        The default value varies based on the
        size of the progress circle.
        | string
        | number
        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 circle.
        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
        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
          | 'xxs'
          | 'xs'
          | 'sm'
          | 'md'
          | 'lg'
          | 'xl'
          | number
          Description
          Governs the height of the progress circle and track.
          Type
          | string
          | number
          Description
          The thickness of the progress ring in pixels. If supplied as a number, it will be used as the pixel value.

          The default value varies based on the
          size of the progress circle.
          Type
          number
          Description
          The value of the progress. If omitted, the component will render as an indefinite progress bar.

          <ProgressRing.Label>

          Label text associated with the progress ring. Renders a <label> 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

          <ProgressRing.ValueText>

          Displays the current progress value as text. Only visible when size is lg or xl. 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

          <ProgressRing.ErrorText>

          Error message displayed when the progress ring is in an invalid state. 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

          <ProgressRing.CircleContainer>

          Container element that wraps the circle and value text. 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

          <ProgressRing.Circle>

          The SVG element that contains the track and bar. Renders an <svg> element.
          PropType
          React children prop.
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          string
          Description
          React children prop.
          Type
          string
          Description
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.

          <ProgressRing.Track>

          The background track of the progress ring. Renders a <circle> element.

          <ProgressRing.Bar>

          The filled portion of the progress ring that represents the current progress value. Renders a <circle> element.