PeakUI

ProgressCircle

A circular indicator for determinate or indeterminate progress

Usage

import {ProgressCircle} from "@peakui/react";

Anatomy

import {ProgressCircle} from "@peakui/react";

export default () => (
  <ProgressCircle aria-label="Loading" value={60}>
    <ProgressCircle.Track>
      <ProgressCircle.TrackCircle />
      <ProgressCircle.FillCircle />
    </ProgressCircle.Track>
  </ProgressCircle>
);

ProgressCircle is a React Aria ProgressBar: it has the progressbar role and the same value attributes, so assistive technology announces it as progress. Give it a name with aria-label or aria-labelledby. When the indicator must be announced as progress, prefer ProgressCircle to Spinner, which is a plain status region.

Examples

Sizes

Colors

Indeterminate

isIndeterminate removes the value and spins the circle.

With Label

Custom SVG Props

Each part is a composable component, so SVG attributes such as strokeWidth can be overridden directly.

The arc's length and rotation are computed for the default geometry, a circle of radius 16 centred at 18 in a 36 by 36 box. Changing r, cx, cy or viewBox therefore also needs strokeDasharray, strokeDashoffset and transform on ProgressCircle.FillCircle, or the arc will not match the ring or the value.

Customization

Tailwind CSS

Global CSS

@layer components {
  .progress-circle__track {
    @apply size-12;
  }

  .progress-circle__fill-circle {
    stroke: var(--color-success);
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The ProgressCircle component uses these CSS classes (view source styles):

Base & Element Classes

  • .progress-circle - Base container
  • .progress-circle__track - The SVG element
  • .progress-circle__track-circle - The ring behind the arc
  • .progress-circle__fill-circle - The progress arc

Size Classes

  • .progress-circle--sm - Small size
  • .progress-circle--md - Medium size, the default
  • .progress-circle--lg - Large size

Color Classes

  • .progress-circle--default
  • .progress-circle--accent
  • .progress-circle--success
  • .progress-circle--warning
  • .progress-circle--danger

Slots

  • [data-slot="progress-circle"]
  • [data-slot="progress-circle-track"]
  • [data-slot="progress-circle-track-circle"]
  • [data-slot="progress-circle-fill-circle"]

CSS Variables

VariablePurpose
--progress-circle-strokeArc color, set by the color classes
--progress-circle-track-strokeRing color

Interactive States

  • Indeterminate: :not([aria-valuenow])
  • Disabled: :disabled, [data-disabled="true"] or [aria-disabled="true"]

API Reference

ProgressCircle

PropTypeDefaultDescription
valuenumber0The current value
minValuenumber0The smallest value
maxValuenumber100The largest value
isIndeterminateboolean-Whether progress is unknown; leaves out aria-valuenow
formatOptionsIntl.NumberFormatOptions{style: 'percent'}Display format of the value
color'default' | 'accent' | 'success' | 'warning' | 'danger''accent'Color of the arc
size'sm' | 'md' | 'lg''md'Size of the circle
childrenReactNode | (values: ProgressBarRenderProps) => ReactNode-Content, or a function of the render props
classNamestring | (values: ProgressBarRenderProps) => string-Additional classes, or a function of the render props
...restEvery React Aria ProgressBar attribute is accepted, including aria-label

ProgressCircle.Track

PropTypeDefaultDescription
childrenReactNode-Holds the two circles
classNamestring-Additional classes
renderDOMRenderFunction<E, undefined>-Replaces the rendered element; E defaults to 'svg'
...restEvery <svg> attribute is accepted, such as viewBox

ProgressCircle.TrackCircle and ProgressCircle.FillCircle

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<E, undefined>-Replaces the rendered element; E defaults to 'circle'
...restEvery <circle> attribute is accepted, such as r, cx, cy and strokeWidth

Render Props

PropTypeDescription
percentagenumber | undefinedThe value as a percentage between minValue and maxValue
valueTextstring | undefinedThe formatted value
isIndeterminatebooleanWhether progress is unknown

On this page