ProgressBar
SM · 950B gzip budgetA determinate or indeterminate progress bar with a real accessible value.
- Category
- Feedback & status
- Budget
- sm, single-purpose control
- External runtime
- React / React DOM only
axe fixtureSSR rendersource scanbundle budget
Preview
Live fixtureUploading
Try the component here. Locale-aware formatting and direction follow the selected language; example content and labels are not automatically translated. Overlay demos use interactive launchers.
Install
npx shadcn@latest add https://gear5-ui.vercel.app/r/progress-bar.jsonCopies the source into your project. Pulls in 1 shared registry item: cn.
New here? Set up Tailwind and import aliases first →Source & props
Edit on GitHub ↗Prop types and inline documentation are included below. This is repository source; the installer rewrites shared imports for your project.
"use client";
import { useId } from "react";
import { cn } from "../lib/cn";
export interface ProgressBarProps {
/** 0–100. Omit for an indeterminate bar. */
value?: number;
label: string;
className?: string;
}
/**
* A determinate or indeterminate progress bar with a real accessible value —
* `aria-valuenow`, not just a filled `<div>` a screen reader has no way to
* read the percentage of.
*/
export function ProgressBar({ value, label, className }: ProgressBarProps) {
const id = useId();
const determinate = typeof value === "number";
const clamped = determinate ? Math.min(100, Math.max(0, value)) : undefined;
return (
<div className={cn("flex flex-col gap-1.5 text-start", className)}>
<div className="flex justify-between text-sm">
<span id={id}>{label}</span>
{determinate && <span aria-hidden="true">{Math.round(clamped!)}%</span>}
</div>
<div
role="progressbar"
aria-labelledby={id}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={determinate ? Math.round(clamped!) : undefined}
className="h-2 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-800"
>
<div
className={cn(
"h-full rounded-full bg-blue-600 transition-[width] duration-300 motion-reduce:transition-none",
!determinate && "w-1/3 animate-pulse motion-reduce:animate-none",
)}
style={determinate ? { width: `${clamped}%` } : undefined}
/>
</div>
</div>
);
}
What CI checks
Quality contract- Bundled, minified and gzipped against its tier budget
- Audited by axe in the state previewed above
- Rendered through react-dom/server with no browser globals
- Scanned for network calls, dangerous sinks, and unguarded animation