Progress toward a goal as a ring, alone or several nested.
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 }), )Installation
pnpm dlx shadcn@latest add checkfu/uicontext/radial-chartUsage
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
Nested
Several limits as nested rings, each read as a meter.
- Workflow runs8,420 / 10K
- Seats41 / 50
- Storage, GB62 / 250
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
ProgressRingView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | — |
valuerequired | number | — | — |
maxrequired | 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 | — | — |
RadialChartView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | — |
ringsrequired | RingDatum[] | — | — |
format | ChartFormat | — | — |
size | number | 140 | Pixels; 140 by default |
locale | string | — | — |
style | Style | — | — |
Accessibility
- Each ring is a
meterwith its value, maximum and a spoken value such as “72 of 100, 72%”.