# Progress ring

> Compact circular SVG progress indicator with centered percentage readout and semantic status tones.

- Kind: ui · Category: Feedback · Interactivity: none
- Install: `npx shadcn@latest add @haze/progress-ring`
- File: `src/components/haze/ui/progress-ring.astro`
- npm dependencies: none
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/progress-ring

## Use 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 when
- Linear file transfer bars belong in progress
- Indeterminate loading waits belong in spinner

## Alternatives
- [progress](https://hazeui.com/ui/progress.md)
- [gauge](https://hazeui.com/ui/gauge.md)
- [spinner](https://hazeui.com/ui/spinner.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| label | `string` |  | yes | Accessible name for the progressbar and optional visible label. |
| value | `number` | 72 | no | Current completion amount. |
| max | `number` | 100 | no | Maximum completion value. |
| size | `"sm" \| "md" \| "lg"` | "md" | no | Ring diameter preset. |
| variant | `"default" \| "info" \| "success" \| "warning" \| "destructive"` | "default" | no | 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.

## Agent prompts

### 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": "https://hazeui.com/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: https://hazeui.com/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.

## Example requests that should lead here
- Add a medium circular progress ring showing 78% storage capacity used

## Source

```astro
---
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>
```
