apps/docs/content/docs/en/react/components/(feedback)/progress-bar.mdx
import { ProgressBar, Label } from '@heroui/react';
<ComponentPreview name="progress-bar-basic" />
import { ProgressBar, Label } from '@heroui/react';
export default () => (
<ProgressBar value={60}>
<Label>Loading</Label>
<ProgressBar.Output />
<ProgressBar.Track>
<ProgressBar.Fill />
</ProgressBar.Track>
</ProgressBar>
);
<ComponentPreview name="progress-bar-sizes" />
<ComponentPreview name="progress-bar-colors" />
Use isIndeterminate when progress cannot be determined.
<ComponentPreview name="progress-bar-indeterminate" />
Use minValue, maxValue, and formatOptions to customize the value range and display format.
<ComponentPreview name="progress-bar-custom-value" />
When no visible label is needed, use aria-label for accessibility.
<ComponentPreview name="progress-bar-without-label" />
<RelatedComponents component="progress-bar" />You can customize individual ProgressBar parts:
import { ProgressBar, Label } from '@heroui/react';
function CustomProgressBar() {
return (
<ProgressBar value={60}>
<Label>Loading</Label>
<ProgressBar.Output />
<ProgressBar.Track className="bg-purple-100 dark:bg-purple-900">
<ProgressBar.Fill className="bg-purple-500" />
</ProgressBar.Track>
</ProgressBar>
);
}
To customize the ProgressBar component classes, you can use the @layer components directive.
@layer components {
.progress-bar {
@apply w-full gap-2;
}
.progress-bar__track {
@apply h-3 rounded-full;
}
.progress-bar__fill {
@apply rounded-full;
}
}
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The ProgressBar component uses these CSS classes (View source styles):
.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.progress-bar--sm - Small size variant (thinner track).progress-bar--md - Medium size variant (default).progress-bar--lg - Large size variant (thicker track).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 variantInherits from React Aria ProgressBar.
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | 0 | The current value |
minValue | number | 0 | The minimum value |
maxValue | number | 100 | The maximum value |
isIndeterminate | boolean | false | Whether 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 |
formatOptions | Intl.NumberFormatOptions | {style: 'percent'} | Number format for the value display |
valueLabel | ReactNode | - | Custom value label content |
children | ReactNode | (values: ProgressBarRenderProps) => ReactNode | - | Content or render prop |
When using the render prop pattern, these values are provided:
| Prop | Type | Description |
|---|---|---|
percentage | number | The percentage of the progress (0-100) |
valueText | string | The formatted value text |
isIndeterminate | boolean | Whether progress is indeterminate |