PeakUI

ProgressBar

Shows determinate or indeterminate progress of an operation

Usage

import {Label, ProgressBar} from "@peakui/react";

Anatomy

import {Label, ProgressBar} from "@peakui/react";

export default () => (
  <ProgressBar value={60}>
    <Label />
    <ProgressBar.Output />
    <ProgressBar.Track>
      <ProgressBar.Fill />
    </ProgressBar.Track>
  </ProgressBar>
);

Examples

Sizes

Colors

Without Label

Without a visible Label, aria-label names the progress bar.

Indeterminate

isIndeterminate removes the value and animates the fill.

Custom Value

minValue, maxValue and formatOptions set the range and the display format.

Customization

Tailwind CSS

Global CSS

@layer components {
  .progress-bar__track {
    @apply h-3 rounded-full;
  }

  .progress-bar__fill {
    @apply rounded-full;
  }

  .progress-bar--success {
    --progress-bar-fill: var(--color-success);
  }
}

Styling Reference

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

CSS Classes

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

Base & Element Classes

  • .progress-bar - Base container (grid layout)
  • .progress-bar__output - Value text display
  • .progress-bar__track - Track background
  • .progress-bar__fill - Filled portion of the track

Size Classes

  • .progress-bar--sm - Small size, thinner track
  • .progress-bar--md - Medium size, the default
  • .progress-bar--lg - Large size, thicker track

Color Classes

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

Slots

  • [data-slot="progress-bar"]
  • [data-slot="progress-bar-output"]
  • [data-slot="progress-bar-track"]
  • [data-slot="progress-bar-fill"]

CSS Variables

VariablePurpose
--progress-bar-fillFill color, set by the color classes

Interactive States

The component supports both CSS pseudo-classes and data attributes:

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

API Reference

ProgressBar

PropTypeDefaultDescription
valuenumber0The current value
minValuenumber0The smallest value
maxValuenumber100The largest value
isIndeterminateboolean-Whether progress is unknown; leaves out aria-valuenow and the fill width
formatOptionsIntl.NumberFormatOptions{style: 'percent'}Display format of the value
valueLabelReactNode-Text announced as the value, such as "2 of 5"
color'default' | 'accent' | 'success' | 'warning' | 'danger''accent'Color of the fill
size'sm' | 'md' | 'lg''md'Height of the track
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

ProgressBar.Output

PropTypeDefaultDescription
childrenReactNodeformatted valueReplaces the formatted value
classNamestring-Additional classes
renderDOMRenderFunction<E, undefined>-Replaces the rendered element; E defaults to 'span'
...restEvery <span> attribute is accepted

ProgressBar.Track

PropTypeDefaultDescription
childrenReactNode-Holds ProgressBar.Fill
classNamestring-Additional classes
renderDOMRenderFunction<E, undefined>-Replaces the rendered element; E defaults to 'div'
...restEvery <div> attribute is accepted

ProgressBar.Fill

PropTypeDefaultDescription
childrenReactNode-Content inside the fill
classNamestring-Additional classes
styleCSSProperties-Merged under the computed width
renderDOMRenderFunction<E, undefined>-Replaces the rendered element; E defaults to 'div'
...restEvery <div> attribute is accepted

Render Props

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

On this page