Progress ring
Compact circular SVG progress indicator with centered percentage readout and semantic status tones.
pnpm dlx shadcn@latest add @haze/progress-ring---
import { cn } from "../../../lib/haze/utils";
interface Props {
label: string;
value?: number;
max?: number;
size?: "sm" | "md" | "lg";
variant?: "default" | "info" | "success" | "warning" | "destructive";
showValue?: boolean;
showLabel?: boolean;
class?: string;
}
const {
label,
value = 72,
max = 100,
size = "md",
variant = "default",
showValue = true,
showLabel = true,
class: className,
} = Astro.props;
const safeMax = max > 0 ? max : 100;
const clamped = Math.min(Math.max(Number.isFinite(value) ? value : 0, 0), safeMax);
const pct = Math.round((clamped / safeMax) * 100);
const offset = 100 - pct;
const dims = {
sm: { box: "size-7", text: "text-[0.6875rem]/none", stroke: 8, outside: true },
md: { box: "size-11", text: "text-xs/none", stroke: 9, outside: false },
lg: { box: "size-16", text: "text-sm/none", stroke: 8, outside: false },
}[size];
const strokes = {
default: "stroke-primary",
info: "stroke-brand",
success: "stroke-success",
warning: "stroke-warning",
destructive: "stroke-destructive",
};
---
<div
role="progressbar"
aria-label={label}
aria-valuemin={0}
aria-valuemax={safeMax}
aria-valuenow={clamped}
aria-valuetext={`${pct}%`}
class={cn("inline-flex items-center gap-3", className)}
>
<div class={cn("relative grid shrink-0 place-items-center", dims.box)}>
<svg aria-hidden="true" viewBox="0 0 36 36" class="size-full -rotate-90">
<circle cx="18" cy="18" r="14" fill="none" stroke-width={dims.stroke * 0.35} class="stroke-muted" />
<circle
cx="18"
cy="18"
r="14"
fill="none"
stroke-width={dims.stroke * 0.35}
stroke-linecap="round"
pathLength="100"
stroke-dasharray="100"
stroke-dashoffset={offset}
class={cn("transition-[stroke-dashoffset] duration-500 ease-snappy", strokes[variant])}
/>
</svg>
{
showValue && !dims.outside && (
<span aria-hidden="true" class={cn("absolute font-mono font-medium text-foreground tabular-nums", dims.text)}>
{pct}%
</span>
)
}
</div>
{
showValue && dims.outside && (
<span aria-hidden="true" class="font-mono text-[0.6875rem]/none font-medium text-foreground tabular-nums">
{pct}%
</span>
)
}
{showLabel && <span class="text-[0.8125rem]/5 font-medium tracking-[-0.01em] text-foreground">{label}</span>}
</div>When to use
- Showing task, quota, or upload completion inline next to a label or list item
- Compact card headers where a full gauge or linear bar takes too much room
When not to use
- Linear file transfer bars belong in progress
- Indeterminate loading waits belong in spinner
Installation
Add the Haze registry to components.json once, then install Progress ring with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/progress-ringnpx shadcn@latest add @haze/progress-ringyarn dlx shadcn@latest add @haze/progress-ringbunx --bun shadcn@latest add @haze/progress-ringFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| label* | string | – | Accessible name for the progressbar and optional visible label. |
| value | number | 72 | Current completion amount. |
| max | number | 100 | Maximum completion value. |
| size | "sm" | "md" | "lg" | "md" | Ring diameter preset. |
| variant | "default" | "info" | "success" | "warning" | "destructive" | "default" | Semantic stroke tone. |
Accessibility
- Exposes native role='progressbar' with aria-valuemin, aria-valuemax, aria-valuenow, and aria-valuetext.
- Decorative SVG arc carries aria-hidden='true' so screen readers announce the semantic percentage cleanly.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Progress ring" with `npx shadcn@latest add @haze/progress-ring`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import ProgressRing from "@/components/haze/ui/progress-ring.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/progress-ring.md
Customize with real content
Adapt the Haze progress-ring ui for our product. Replace the demo values of these props with our real content: label, value, max, size, variant. Keep the layout, the heading level rules and these accessibility details: Exposes native role='progressbar' with aria-valuemin, aria-valuemax, aria-valuenow, and aria-valuetext. Decorative SVG arc carries aria-hidden='true' so screen readers announce the semantic percentage cleanly. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using progress-ring, check it fits: use it when showing task, quota, or upload completion inline next to a label or list item; compact card headers where a full gauge or linear bar takes too much room. Avoid it when linear file transfer bars belong in progress; indeterminate loading waits belong in spinner. Alternatives: @haze/progress, @haze/gauge, @haze/spinner.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.