# Progress Ring

> Progress toward a goal as a ring, alone or several nested.

Page: https://uicontext.com/docs/components/progress-ring

Group: Charts.

## When to use

Progress toward a goal as a ring, alone or several nested. Use [Progress](https://uicontext.com/docs/components/progress.md) instead when the goal is a single bar.

## Usage

```ts
import { ProgressRing } from "./ui/uicontext/components/charts/Radial.ts"

export const SeatsRing = <M>(h: Html.H<M>, used: number, seats: number) =>
	ProgressRing(h, { label: "Seats used", value: used, max: seats, caption: "of seats" })
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### Progress toward goals

The example the page opens with: Progress Ring in “Progress toward goals”.

```ts title="src/demo.ts" source="www/src/examples/progress-ring/demo.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { ProgressRing } from "./ui/uicontext/components/charts/Radial.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({ row: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "center", gap: space.xxl } })

// Seats on the plan, the quarter's revenue goal, and storage past its limit, where the ring turns the
// warning color.
export const PlanRings = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.row)).children(
		ProgressRing(h, { label: "Seats used", value: 72, max: 100, caption: "of seats", size: 112 }),
		ProgressRing(h, { label: "Quarterly revenue goal", value: 2_140_000, max: 3_000_000, format: { style: "currency", currency: "USD" }, caption: "of goal", size: 112, color: 6 }),
		ProgressRing(h, { label: "Storage", value: 118, max: 100, format: { style: "unit", unit: "gigabyte" }, caption: "of 100 GB", size: 112 }),
		ProgressRing(h, { label: "Onboarding checklist", value: 3, max: 5, size: 40 }),
	)
```

### Nested

Several limits as nested rings, each read as a meter.

```ts title="src/nested.ts" source="www/src/examples/progress-ring/nested.ts"
import type { Html } from "effect/ui/html"
import { RadialChart } from "./ui/uicontext/components/charts/Radial.ts"

// This month's plan limits, one ring each, named with their values beside the rings.
export const PlanLimits = <M>(h: Html.H<M>) =>
	RadialChart(h, {
		label: "Plan limits this month",
		rings: [
			{ id: "runs", label: "Workflow runs", value: 8_420, max: 10_000 },
			{ id: "seats", label: "Seats", value: 41, max: 50 },
			{ id: "storage", label: "Storage, GB", value: 62, max: 250 },
		],
	})
```

## API reference

### ProgressRing (view function)

**Options**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `string` | — | — |
| `value` (required) | `number` | — | — |
| `max` (required) | `number` | — | — |
| `format` | `ChartFormat` | — | — |
| `caption` | `string` | — | Under the share in the middle: "of seats" |
| `size` | `number` | `96` | Pixels; 96 by default |
| `color` | `ChartColor` | — | — |
| `locale` | `string` | — | — |
| `style` | `Style` | — | — |

### RadialChart (view function)

**Options**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `string` | — | — |
| `rings` (required) | `RingDatum[]` | — | — |
| `format` | `ChartFormat` | — | — |
| `size` | `number` | `140` | Pixels; 140 by default |
| `locale` | `string` | — | — |
| `style` | `Style` | — | — |

## Keyboard and accessibility

- Each ring is a `meter` with its value, maximum and a spoken value such as “72 of 100, 72%”.

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/progress-ring
```

With npm: `npx shadcn@latest add checkfu/uicontext/progress-ring`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/progress-ring`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/progress-ring`.

It writes these files:

- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/charts/Data.ts`
- `src/ui/uicontext/components/charts/Format.ts`
- `src/ui/uicontext/components/charts/Frame.ts`
- `src/ui/uicontext/components/charts/Radial.ts`
- `src/ui/uicontext/components/charts/Scale.ts`
- `src/ui/uicontext/components/charts/chart.stylex.ts`
- `src/ui/uicontext/components/charts/slots.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/charts/Radial.ts](https://github.com/checkfu/uicontext/blob/main/src/charts/Radial.ts)

## Related

- [Chart Foundations](https://uicontext.com/docs/components/chart-foundations.md) (`chart-foundations`): The scales, formats, legend and tooltip every chart shares.
- [Line Chart](https://uicontext.com/docs/components/line-chart.md) (`line-chart`): Values over time for one or many series, with dashed comparisons and forecasts.
- [Area Chart](https://uicontext.com/docs/components/area-chart.md) (`area-chart`): Totals over time and what makes them up, stacked or as shares of 100%.
- [Bar Chart](https://uicontext.com/docs/components/bar-chart.md) (`bar-chart`): Compare categories with grouped, stacked or sideways bars.
- [Combo Chart](https://uicontext.com/docs/components/combo-chart.md) (`combo-chart`): Bars and a line on one time axis, each read against its own scale.
- [Donut Chart](https://uicontext.com/docs/components/donut-chart.md) (`donut-chart`): Shares of one total, with the total in the middle.
