Data display
Progress Bar
4px track for usage, quotas and rates.
Label on top
AI credits6,240 / 10,000
Resets Oct 1 · Growth plan
Enrichments2,780 / 3,000
Reply rate
import { ProgressBar } from "@/components/ui/progress-bar";
export default function Example() {
return (
<div className="flex w-full max-w-sm flex-col gap-5">
<ProgressBar label="AI credits" value={6240} max={10000} showValue caption="Resets Oct 1 · Growth plan" />
<ProgressBar label="Enrichments" value={2780} max={3000} showValue tone="warning" />
<ProgressBar label="Reply rate" value={8.6} max={15} tone="neutral" />
</div>
);
}Percentage on the right
40%
75%
92%
import { ProgressBar } from "@/components/ui/progress-bar";
export default function Example() {
return (
<div className="flex w-full max-w-sm flex-col gap-4">
<ProgressBar label="Profile" value={40} labelPosition="right" />
<ProgressBar label="Onboarding" value={75} labelPosition="right" tone="success" />
<ProgressBar label="Storage" value={92} labelPosition="right" tone="error" />
</div>
);
}Installation
Components are copied into your project — no runtime package.
Create a
progress-bar.tsxfile and paste the following code into it.src/components/ui/progress-bar.tsximport { cx } from "@/utils/cx"; export interface ProgressBarProps { value: number; max?: number; label?: string; /** Shows `value / max` on the right of the label. */ showValue?: boolean; tone?: "accent" | "neutral" | "success" | "warning" | "error"; caption?: string; /** `top` puts label and value above the bar; `right` puts the percentage beside it. */ labelPosition?: "top" | "right"; className?: string; } const tones = { accent: "bg-accent", neutral: "bg-chart-neutral", success: "bg-success", warning: "bg-warning", error: "bg-error" }; /** 4px track used for usage, quotas and sequence rates. */ export function ProgressBar({ value, max = 100, label, showValue, tone = "accent", caption, labelPosition = "top", className }: ProgressBarProps) { const pct = Math.max(0, Math.min(100, (value / max) * 100)); if (labelPosition === "right") { return ( <div className={cx("flex items-center gap-3", className)}> <div role="progressbar" aria-valuenow={value} aria-valuemax={max} aria-label={label ?? "Progress"} className="h-1.5 flex-1 overflow-hidden rounded-full bg-active"> <div className={cx("h-full rounded-full transition-[width]", tones[tone])} style={{ width: `${pct}%` }} /> </div> <span className="w-10 text-right text-sm font-medium tabular text-fg">{Math.round(pct)}%</span> </div> ); } return ( <div className={cx("flex flex-col gap-2", className)}> {(label || showValue) && ( <div className="flex items-center justify-between gap-3 text-sm"> {label && <span className="text-fg-secondary">{label}</span>} {showValue && ( <span className="tabular"> <span className="font-medium text-fg">{value.toLocaleString("en-US")}</span> <span className="text-fg-muted"> / {max.toLocaleString("en-US")}</span> </span> )} </div> )} <div role="progressbar" aria-valuenow={value} aria-valuemax={max} aria-label={label} className="h-1 overflow-hidden rounded-full bg-active"> <div className={cx("h-full rounded-full transition-[width]", tones[tone])} style={{ width: `${pct}%` }} /> </div> {caption && <span className="text-sm text-fg-muted">{caption}</span>} </div> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.