Progress
A progress bar showing completion status
Installation
pnpm dlx shadcn@latest add https://prototyper-ui.com/r/progress.jsonnpx shadcn@latest add https://prototyper-ui.com/r/progress.jsonyarn dlx shadcn@latest add https://prototyper-ui.com/r/progress.jsonbunx --bun shadcn@latest add https://prototyper-ui.com/r/progress.jsonThis will add the following files to your project:
components/ui/progress.tsx
Usage
import { Progress, ProgressLabel } from "@/components/ui/progress"
<Progress value={50}>
<ProgressLabel>Loading...</ProgressLabel>
</Progress>Anatomy
<Progress>
<ProgressLabel />
<ProgressValue />
{/* ProgressTrack and ProgressIndicator are rendered internally by Progress */}
</Progress>| Sub-component | data-slot | Purpose | Required |
|---|---|---|---|
Progress | progress | Root provider with built-in track/indicator | Yes |
ProgressTrack | progress-track | Background track for the indicator | Yes |
ProgressIndicator | progress-indicator | Filled portion representing progress | Yes |
ProgressLabel | progress-label | Accessible label for the progress bar | No |
ProgressValue | progress-value | Displays the current value as text | No |
Note:
ProgressTrackandProgressIndicatorare rendered automatically inside theProgresscomponent. You do not need to include them manually.
Examples
Custom Format
Reusable
Value Format
Styling
Data Slots
Use data-slot attributes to target specific parts of the progress bar:
| Slot name | Element |
|---|---|
progress | Root wrapper |
progress-track | Background track bar |
progress-indicator | Filled indicator bar |
progress-label | Label text |
progress-value | Value text |
Customization Examples
/* Make the progress track taller */
[data-slot="progress-track"] {
@apply h-4 rounded-lg;
}
/* Custom indicator with gradient */
[data-slot="progress-indicator"] {
@apply bg-gradient-to-r from-green-500 to-emerald-500;
}{/* Override color via the color prop */}
<Progress value={75} color="success">
<ProgressLabel>Upload</ProgressLabel>
</Progress>API Reference
Progress
Root component that provides progress value context and renders the track and indicator internally.
Prop
Type
All Base UI Progress.Root props are forwarded via ...props.
ProgressTrack
Background track that contains the indicator. Rendered automatically by Progress.
Prop
Type
All Base UI Progress.Track props are forwarded via ...props.
ProgressIndicator
The filled portion of the track representing current progress. Rendered automatically by Progress.
Prop
Type
All Base UI Progress.Indicator props are forwarded via ...props.
ProgressLabel
Accessible label for the progress bar.
Prop
Type
All Base UI Progress.Label props are forwarded via ...props.
ProgressValue
Displays the current progress value as formatted text.
Prop
Type
All Base UI Progress.Value props are forwarded via ...props.
progressTrackVariants
A cva helper exported for applying progress track styles outside of the <ProgressTrack> component.
import { progressTrackVariants } from "@/components/ui/progress"
<div className={progressTrackVariants({ color: "success" })}>Custom track</div>progressIndicatorVariants
A cva helper exported for applying progress indicator styles outside of the <ProgressIndicator> component.
import { progressIndicatorVariants } from "@/components/ui/progress"
<div className={progressIndicatorVariants({ color: "warning" })}>Custom indicator</div>Accessibility
Keyboard Interactions
The progress bar is a non-interactive display element and does not have keyboard interactions. Focus management is handled by surrounding interactive elements.
ARIA Attributes
- The progress bar renders with
role="progressbar"via the Base UI primitive. aria-valuenowreflects the current value.aria-valueminandaria-valuemaxdefine the range.- When
valueisnull, the progress bar enters indeterminate mode andaria-valuenowis removed. aria-labelledbyis automatically linked toProgressLabelwhen present.- The
data-indeterminateattribute is set when value isnull, anddata-completeis set when value equals max. - Screen readers announce the progress value and its label.