Gauge Chart for React
A React gauge chart shows one number against its scale as a semicircle or a speedometer whose needle springs into place. Pass one number as value, with optional min, max, target and colored bands.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/gauge-chart.jsonApplication health
GaugeChartGaugeTablegaugeLegenddefaultGaugeChartLabels- +2 more
Semicircle with bands and a target
Apdex score. Take a new reading: the needle springs to it and the digits roll. Hover a band, the target or the needle, or focus the gauge and use the arrow keys.
Application health
Apdex, last 15 minutes
import { GaugeChart } from "@/components/sheenui/charts/gauge-chart";
import { type GaugeBand } from "@/components/sheenui/charts/gauge-chart/model";
// Package build (after the first npm release, or a packed tarball): import { GaugeChart, type GaugeBand } from "@sheenui/theme";
const bands: GaugeBand[] = [
{ to: 0.7, label: "Poor", tone: "danger" },
{ to: 0.85, label: "Fair", tone: "warning" },
{ to: 1, label: "Good", tone: "success" },
];
export function Example() {
const apdex = 0.91; // your latest reading
return (
<GaugeChart
value={apdex}
min={0}
max={1}
target={0.85}
bands={bands}
label="Apdex"
numberFormat={{ minimumFractionDigits: 2, maximumFractionDigits: 2 }}
aria-label="Apdex score"
/>
);
}Speedometer
shape="speedometer" sweeps 270°. Drag the slider: the needle chases the value on a spring. higherIsBetter={false} turns a value above the target into a warning.
Cluster CPU
Average across 12 nodes
import { GaugeChart } from "@/components/sheenui/charts/gauge-chart";
import { type GaugeBand } from "@/components/sheenui/charts/gauge-chart/model";
// Package build (after the first npm release, or a packed tarball): import { GaugeChart, type GaugeBand } from "@sheenui/theme";
const bands: GaugeBand[] = [
{ to: 60, label: "Normal", tone: "success" },
{ to: 85, label: "Busy", tone: "warning" },
{ to: 100, label: "Overloaded", tone: "danger" },
];
export function Example() {
const cpu = 72; // percent, from your metrics
return (
<GaugeChart
shape="speedometer"
value={cpu}
target={80}
higherIsBetter={false}
bands={bands}
label="CPU load"
numberFormat={{ style: "unit", unit: "percent" }}
aria-label="CPU load"
/>
);
}Plain arc, custom format
Without bands the arc fills with one color, lighter at the start. With format the number counts up instead of rolling its digits.
Revenue goal
MRR against the $120K target for Q4
import { GaugeChart } from "@/components/sheenui/charts/gauge-chart";
// Package build (after the first npm release, or a packed tarball): import { GaugeChart } from "@sheenui/theme";
<GaugeChart
value={68.4}
max={120}
color={3}
label="Monthly recurring revenue"
format={(n) => `$${Number(n.toFixed(1))}K`}
aria-label="Monthly recurring revenue against a $120K goal"
/>Files to copy
13 folders · 29 files · 4 packages
- From
theme/src/ components/charts/{gauge-chart.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-pointer.tsx, chart-tip.tsx, chart-utils.ts}components/charts/chart-parts/components/charts/gauge-chart/components/drawer/parts/sheet.tsxcomponents/kbd/components/menu/components/number-ticker/components/skeleton/components/status-icons/hooks/{use-controllable.ts, use-direction.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{canvas-effects.ts, cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/gauge-chart.jsonRegistry item: gauge-chart. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".
Props
GaugeChartLabels keys and English defaults (15)
GaugeTable props
Keyboard
Accessibility
- The chart is one focusable figure: its aria-label is the chart title, a one-line hint describes how to read it, and in a ChartCard with a table view aria-details points at that table. Each move is announced politely, once. The value, its band (icon and name) and its distance from the target are text, so status never rests on color alone.
- For a non-visual reading, give ChartCard's table prop a GaugeTable; the Chart / Table tabs then expose each value as plain table cells.
- Under reduced motion nothing morphs: the arc and the needle render at the final value and new data replaces the old at once.
All exports on this page
GaugeChart— A gauge for one number against its scale: a semicircle or a 270° speedometer whose needle springs to the value (a touch of overshoot, then it settles).GaugeTable— The gauge in text: the value, the target, the scale and every band with its range.defaultGaugeChartLabels— The built-in English strings of GaugeChart; spread it into your own labels and change what you need.gaugeLegend— Legend items for a gauge's bands (a tone's colour always travels with its label).
When to use the gauge chart
- Use it as a speedometer chart for a single health number against its scale, such as an Apdex score, CPU load or a quality rating, with colored bands that name the range the needle sits in.
- Add a target when the number has a goal: a tick crosses the arc and the readout states the distance from it, with higherIsBetter set to false for latency or cost.
- Pick the speedometer shape for dashboards that want a dial look and the semicircle for a flatter card, and format the number with numberFormat for percent or unit styles.
- Skip it when you show many KPIs in a list, because a Bullet chart fits a row each, or when the value needs history, where a Sparkline or Line chart is the right tool.
- Pair it with ChartCard and GaugeTable for a text view, a Badge to repeat the band name, and Skeleton while the value loads.
Frequently asked questions
Related pages
48 charts pages in all: browse them on Charts.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .