Back to Heroui

ProgressBar

apps/docs/content/docs/en/react/components/(feedback)/progress-bar.mdx

3.2.33.8 KB
Original Source

Usage

tsx
import { ProgressBar, Label } from '@heroui/react';

<ComponentPreview name="progress-bar-basic" />

Anatomy

tsx
import { ProgressBar, Label } from '@heroui/react';

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

Examples

Sizes

<ComponentPreview name="progress-bar-sizes" />

Colors

<ComponentPreview name="progress-bar-colors" />

Without Label

When no visible label is needed, use aria-label for accessibility.

<ComponentPreview name="progress-bar-without-label" />

Indeterminate

Use isIndeterminate when progress cannot be determined.

<ComponentPreview name="progress-bar-indeterminate" />

Custom Value Scale

Use minValue, maxValue, and formatOptions to customize the value range and display format.

<ComponentPreview name="progress-bar-custom-value" />

Customization

Tailwind CSS

<ComponentPreview name="progress-bar-custom-styles" />

Global CSS

To customize the ProgressBar component classes, you can use the @layer components directive. Learn more.

css
@layer components {
  .progress-bar {
    @apply w-full gap-2;
  }

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

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

Styling Reference

HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.

CSS Classes

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

Base & Element Classes [!toc]

  • .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 [!toc]

  • .progress-bar--sm - Small size variant (thinner track)
  • .progress-bar--md - Medium size variant (default)
  • .progress-bar--lg - Large size variant (thicker track)

Color Classes [!toc]

  • .progress-bar--default - Default color variant
  • .progress-bar--accent - Accent color variant
  • .progress-bar--success - Success color variant
  • .progress-bar--warning - Warning color variant
  • .progress-bar--danger - Danger color variant

API Reference

ProgressBar

Inherits from React Aria ProgressBar.

PropTypeDefaultDescription
valuenumber0The current value
minValuenumber0The minimum value
maxValuenumber100The maximum value
isIndeterminatebooleanfalseWhether progress is indeterminate
size"sm" | "md" | "lg""md"Size of the progress track
color"default" | "accent" | "success" | "warning" | "danger""accent"Color of the fill bar
formatOptionsIntl.NumberFormatOptions{style: 'percent'}Number format for the value display
valueLabelReactNode-Custom value label content
childrenReactNode | (values: ProgressBarRenderProps) => ReactNode-Content or render prop

Render Props

When using the render prop pattern, these values are provided:

PropTypeDescription
percentagenumberThe percentage of the progress (0-100)
valueTextstringThe formatted value text
isIndeterminatebooleanWhether progress is indeterminate
<RelatedComponents component="progress-bar" />