# Activity rings

> Three daily goals as concentric rings beside a tight legend, with the week underneath: pick a day and the rings sweep to it.

Rings are the quickest way to see whether today’s goals are done, and most versions are a static picture. These sweep round from the top the first time they’re seen, outer first, while the legend beside them rolls up each figure against its goal and its share. Underneath, the week sits as seven small rings: pick a day and the big rings sweep to it, the day’s name morphs above them and every figure rolls. A goal beaten carries on round for a second lap with a dot marking how far it got, the way a watch shows it. Point at a ring or its row and the other two step back. Days still to come are quiet and can’t be picked.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/activity-rings.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): `number-roll`, `text-morph`
- Docs and live preview: https://hairlineui.com/ui/activity-rings
- Registry item (source): https://hairlineui.com/r/activity-rings.json

## Usage

```tsx
import { ActivityRings } from "@/components/activity-rings";

<ActivityRings
  goals={[
    { id: "orders", label: "Orders", goal: 120 },
    { id: "revenue", label: "Revenue", goal: 1200, format: { style: "currency", currency: "USD" } },
    { id: "regulars", label: "Regulars back", goal: 15 },
  ]}
  days={week} // [{ key: "2026-10-09", label: "F", title: "Friday 9 October", values: [93, 940, 12] }, …]
/>
```

## From your own numbers

Build the week on the server with one value per goal per day, and null for the days still to come.

```tsx
import { ActivityRings, type RingDay } from "@/components/activity-rings";
import { db } from "@/lib/db";

export async function TodayGoals() {
  const monday = startOfWeek(new Date());
  const rows = await db.dailyTotals({ from: monday, days: 7 }); // [{ day, orders, revenue, regulars } | null]
  const days: RingDay[] = rows.map((r, i) => {
    const d = new Date(monday);
    d.setDate(d.getDate() + i);
    return {
      key: d.toISOString().slice(0, 10),
      label: d.toLocaleDateString("en-GB", { weekday: "narrow" }),
      title: d.toLocaleDateString("en-GB", { weekday: "long", day: "numeric", month: "long" }),
      values: r ? [r.orders, r.revenue, r.regulars] : [null, null, null],
    };
  });
  return <ActivityRings goals={GOALS} days={days} />;
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `goals` | `RingGoal[]` | – | Up to three, outermost first: { id, label, goal, format? }. |
| `days` | `RingDay[]` | – | The week, oldest first: { key, label, title?, values } with null values for days to come. |
| `value / defaultValue` | `string` | `the last day with data` | The day on show, by key; controlled or not. |
| `onValueChange` | `(key: string) => void` | – | Called when the day changes. |
| `locales` | `string \| string[]` | – | For number formatting. |

## States

- **arrive**: In view for the first time, each ring sweeps from the top (1100ms, 120ms apart, outer first), the week’s small rings follow 40ms apart, and every figure rolls up from zero.
- **day**: Picking a day sweeps the big rings to its shares, morphs the title to its name and rolls the figures. Days after the last one with data are dimmed and aria-disabled.
- **past**: Over 100%, a second lap draws over the first and a dot ringed in the surface colour marks its lead, fading in as the lap lands.
- **focus**: Pointing at a ring’s row dims the other rings to 30% and the other rows to 45%.

## What it handles

Activity rings are usually a static picture, or a chart library bent into shape. This takes three goals and a week of numbers and handles the drawing, the second lap and the switching between days.

- **Three goals, three rings**: Outermost first, each in its own colour from your theme, with the figures rolling up as they arrive.
- **A legend in real text**: Each goal’s figure, target and share is written out, so the rings never carry the meaning alone.
- **Going past 100%**: A goal that is beaten carries on round for a second lap, with a dot marking how far it got.
- **Look back at any day**: The week sits underneath as seven small rings; pick one and the big rings sweep to that day.
- **Days to come stay quiet**: Days without data are dimmed and can’t be picked.
- **Fits its space**: It sizes to its own width, steps down on narrow cards, and the days work with arrow keys.

## Replaces

SVG arc maths, a chart library, a week picker, number formatting, a legend

## Where it fits

- **Fitness and health apps**: Daily move, exercise and stand-style goals, with the week underneath.
- **Habit and goal trackers**: Three goals for today, and a way to look back at earlier days.
- **Learning apps**: Daily minutes, lessons and practice goals for students.
- **Team dashboards**: Three daily targets, such as calls, demos and replies, against what a person or team has done.

## Notes

- Grey in a new shadcn project? Its default theme sets --chart-1 to --chart-5 to greys. Set five colours, light and dark, as in Theming › Chart colours (/ui/theming#charts).
- The legend is real text: each goal’s figure, target and share, so the rings never carry meaning on their own.
- The week is a radio group: arrow keys, Home and End move between days with data, and each day’s name and shares are its label.
- Colours are --chart-1 to --chart-3 from your theme; each ring’s track is a light step of its own colour.
- It sizes to its own width: below about 450px the rings, type and spacing step down.
- Installs Number roll and Text morph. With reduced motion the rings are simply filled.

License: MIT (https://hairlineui.com/license#components)
