# Activity rings card

> High-impact concentric triple progress rings with bold rounded strokes, subtle halo depth, and minimal color-matched tabular readouts.

- Kind: ui · Category: Data display · Interactivity: none
- Install: `npx shadcn@latest add @haze/apple-activity-card`
- File: `src/components/haze/ui/apple-activity-card.astro`
- npm dependencies: none
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/apple-activity-card

## Use when
- A summary card tracks three concurrent daily or sprint goals against numeric targets at a glance
- You want an iconic radial ring graphic paired with clean tabular-nums ratios and units

## Avoid when
- Only a single completion percentage is needed. Use progress-ring.
- Parts add up to a shared 100% total rather than independent targets. Use donut-chart.

## Alternatives
- [progress-ring](https://hazeui.com/ui/progress-ring.md)
- [donut-chart](https://hazeui.com/ui/donut-chart.md)
- [usage-meter](https://hazeui.com/ui/usage-meter.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| title | `string` | "Activity Rings" | no | Centered card heading text. |
| rings | `{ label: string; value: number; target: number; unit: string; tone?: "destructive" \| "success" \| "brand" \| "warning" }[]` |  | no | Up to three concentric activity rings ordered from outer to inner. |
| headingLevel | `2 \| 3 \| 4` | 3 | no | Heading level for the card title. |
| class | `string` |  | no | Additional classes on the outer card element. |

## Accessibility
- The concentric rings SVG exposes role="img", aria-label, and an embedded <title> summarizing all three rings.
- Each numeric readout row carries role="progressbar" with aria-valuemin, aria-valuemax, aria-valuenow, and aria-valuetext so progress is never conveyed by color alone.

## Agent prompts

### Install and use

Install the Haze UI component "Activity rings card" with `npx shadcn@latest add @haze/apple-activity-card`. 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 AppleActivityCard from "@/components/haze/ui/apple-activity-card.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/apple-activity-card.md

### Customize with real content

Adapt the Haze apple-activity-card ui for our product. Replace the demo values of these props with our real content: title, rings, headingLevel, class. Keep the layout, the heading level rules and these accessibility details: The concentric rings SVG exposes role="img", aria-label, and an embedded <title> summarizing all three rings. Each numeric readout row carries role="progressbar" with aria-valuemin, aria-valuemax, aria-valuenow, and aria-valuetext so progress is never conveyed by color alone. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using apple-activity-card, check it fits: use it when a summary card tracks three concurrent daily or sprint goals against numeric targets at a glance; you want an iconic radial ring graphic paired with clean tabular-nums ratios and units. Avoid it when only a single completion percentage is needed. use progress-ring.; parts add up to a shared 100% total rather than independent targets. use donut-chart.. Alternatives: @haze/progress-ring, @haze/donut-chart, @haze/usage-meter.

## Example requests that should lead here
- Show a three-ring Activity Rings card tracking Move calories, Exercise minutes, and Stand hours.
- Build a concentric activity rings card summarizing daily Focus, Active, and Stand targets.

## Source

```astro
---
import { cn } from "../../../lib/haze/utils";

type RingTone = "destructive" | "success" | "brand" | "warning";

interface ActivityRing {
  label: string;
  value: number;
  target: number;
  unit: string;
  tone?: RingTone;
}

interface Props {
  title?: string;
  rings?: ActivityRing[];
  headingLevel?: 2 | 3 | 4;
  class?: string;
}

const {
  title = "Activity Rings",
  rings = [
    { label: "Move", value: 456, target: 800, unit: "CAL", tone: "destructive" },
    { label: "Exercise", value: 33, target: 30, unit: "MIN", tone: "success" },
    { label: "Stand", value: 9, target: 12, unit: "HR", tone: "brand" },
  ],
  headingLevel = 3,
  class: className,
} = Astro.props;

const Heading = ({ 2: "h2", 3: "h3", 4: "h4" } as const)[headingLevel];
const defaultTones: RingTone[] = ["destructive", "success", "brand"];
const radii = [75, 56, 37];

const textTone: Record<RingTone, string> = {
  destructive: "text-destructive",
  success: "text-success",
  brand: "text-brand",
  warning: "text-warning",
};

const fmt = new Intl.NumberFormat("en", { maximumFractionDigits: 1 });

const normalized = rings.slice(0, 3).map((ring, index) => {
  const safeTarget = Number.isFinite(ring.target) && ring.target > 0 ? ring.target : 1;
  const safeValue = Number.isFinite(ring.value) && ring.value > 0 ? ring.value : 0;
  const rawPct = Math.round((safeValue / safeTarget) * 100);
  const fillPct = Math.min(100, rawPct);
  const overflowPct = rawPct > 100 ? Math.min(85, rawPct - 100) : 0;
  const tone = ring.tone ?? defaultTones[index % defaultTones.length]!;
  return {
    ...ring,
    safeTarget,
    safeValue,
    rawPct,
    fillPct,
    overflowPct,
    radius: radii[index]!,
    tone,
  };
});

const svgSummary = normalized.length
  ? `${title}: ${normalized
      .map((r) => `${r.label} ${fmt.format(r.safeValue)} of ${fmt.format(r.safeTarget)} ${r.unit} (${r.rawPct}%)`)
      .join(", ")}.`
  : `${title}: no activity rings configured.`;
---

<article
  class={cn(
    "w-full max-w-[380px] min-w-0 rounded-xl border border-border bg-card p-6 text-card-foreground",
    className,
  )}
>
  <Heading class="mb-5 text-center text-[1.0625rem]/6 font-semibold tracking-tight text-card-foreground wrap-anywhere">
    {title}
  </Heading>

  {
    normalized.length > 0 && (
      <div class="flex min-w-0 flex-col items-center justify-center gap-6 sm:flex-row">
        <svg
          role="img"
          aria-label={svgSummary}
          viewBox="0 0 180 180"
          class="size-40 shrink-0 -rotate-90 sm:size-44"
        >
          <title>{svgSummary}</title>
          {normalized.map((ring) => (
            <g>
              <circle
                cx="90"
                cy="90"
                r={ring.radius}
                fill="none"
                stroke="currentColor"
                stroke-width="14"
                stroke-opacity="0.2"
                class={textTone[ring.tone]}
              />
              {ring.fillPct > 0 && (
                <circle
                  cx="90"
                  cy="90"
                  r={ring.radius}
                  fill="none"
                  stroke="currentColor"
                  stroke-width="14"
                  stroke-linecap="round"
                  pathLength="100"
                  stroke-dasharray={`${ring.fillPct} 100`}
                  class={cn("transition-[stroke-dasharray] duration-500 ease-snappy motion-reduce:transition-none", textTone[ring.tone])}
                />
              )}
              {ring.overflowPct > 0 && (
                <>
                  {/* The lap past 100 %: a card-coloured outline 1.5 px wider than the ring separates its rounded end from the ring below (no shadow). */}
                  <circle
                    cx="90"
                    cy="90"
                    r={ring.radius}
                    fill="none"
                    stroke="currentColor"
                    stroke-width="17"
                    stroke-linecap="round"
                    pathLength="100"
                    stroke-dasharray={`${ring.overflowPct} 100`}
                    class="text-card"
                  />
                  <circle
                    cx="90"
                    cy="90"
                    r={ring.radius}
                    fill="none"
                    stroke="currentColor"
                    stroke-width="14"
                    stroke-linecap="round"
                    pathLength="100"
                    stroke-dasharray={`${ring.overflowPct} 100`}
                    class={textTone[ring.tone]}
                  />
                </>
              )}
            </g>
          ))}
        </svg>

        <ul role="list" class="min-w-0 space-y-3.5 text-center sm:text-left">
          {normalized.map((ring) => (
            <li class="min-w-0">
              <div
                role="progressbar"
                aria-label={ring.label}
                aria-valuemin={0}
                aria-valuemax={ring.safeTarget}
                aria-valuenow={ring.safeValue}
                aria-valuetext={`${fmt.format(ring.safeValue)} of ${fmt.format(ring.safeTarget)} ${ring.unit} (${ring.rawPct}%)`}
                class="grid min-w-0 gap-0.5"
              >
                <span class="text-[0.6875rem]/4 font-semibold tracking-wider text-muted-foreground uppercase">
                  {ring.label}
                </span>
                <span class={cn("text-xl/6 font-semibold tracking-tight tabular-nums", textTone[ring.tone])}>
                  {fmt.format(ring.safeValue)}/{fmt.format(ring.safeTarget)}
                  <span class="ml-1 text-xs/4 font-semibold tracking-wider uppercase opacity-85">{ring.unit}</span>
                </span>
              </div>
            </li>
          ))}
        </ul>
      </div>
    )
  }
</article>
```
