Skip to content

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.json

Application health

Use the arrow keys to read the value, the target and each band.

  • GaugeChart
  • GaugeTable
  • gaugeLegend
  • defaultGaugeChartLabels
  • +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

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.

CPU load
72

Cluster CPU

Average across 12 nodes

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

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.tsx
  • components/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.ts
  • lib/{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

PropTypeDefaultDescription
value (required)numberNoneThe number to show. Required.
minnumber0Start of the scale.
maxnumber100End of the scale.
targetnumber0A goal, drawn as a tick across the arc.
bandsreadonly GaugeBand[]NoneColoured ranges, lowest first. The arc lights up to the needle in each band's colour.
shape"semicircle" | "speedometer""semicircle"Sets the sweep of the arc: "semicircle" (180°) or "speedometer" (270°).
labelReactNodeNoneCaption under the number, e.g. "Apdex" or "CPU".
colorChartColor1Palette slot (1–8) of the arc when there are no bands.
ticksbooleantruePrint the scale around the arc.
numberFormatIntl.NumberFormatOptionsNoneIntl options for every number (the big one rolls its digits). E.g. { style: "percent" } or { style: "unit", unit: "millisecond" }.
format((n: number) => string)NoneFormat numbers yourself instead (the big number then counts up instead of rolling its digits).
localestringthe browser'sLocale of the number formats.
higherIsBetterbooleantrueIs beating the target good (score) or bad (latency, cost)? Picks the tone of the delta.
heightnumber260Largest height (px). The gauge fits its card's width up to this.
labelsPartial<GaugeChartLabels>defaultGaugeChartLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultGaugeChartLabels. All 15 keys of GaugeChartLabels are listed in the key table under the props table.
aria-label (required)stringNoneNames the gauge for assistive tech (required).
classNamestringNoneAdds extra classes to the outer element.
GaugeChartLabels keys and English defaults (15)
Pass any key in labels; the rest keep the defaults of defaultGaugeChartLabels.
KeyEnglish default
roleDescriptiongauge
instructionsUse the arrow keys to read the value, the target and each band.
valueValue
targetTarget
bandBand
vsTarget(delta) => `${delta} vs target`
onTargetOn target
scale(min, max) => `Scale ${min} to ${max}`
between(low, high) => `${low}–${high}`
currentCurrent band
belowScaleBelow the scale
aboveScaleAbove the scale
measureMeasure
rangeRange
noDataNo data

GaugeTable props

PropTypeDefaultDescription
maxnumber100End of the scale.
minnumber0Start of the scale.
targetnumberNoneA goal, drawn as a tick across the arc.
format((n: number) => string)NoneFormat numbers yourself instead (the big number then counts up instead of rolling its digits).
value (required)numberNoneThe number to show. Required.
labelsPartial<GaugeChartLabels>defaultGaugeChartLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultGaugeChartLabels. All 15 keys of GaugeChartLabels are listed in the key table under the props table.
localestringthe browser'sLocale of the number formats.
bandsreadonly GaugeBand[]NoneColoured ranges, lowest first. The arc lights up to the needle in each band's colour.
numberFormatIntl.NumberFormatOptions{ maximumFractionDigits: 2 }Intl options for every number (the big one rolls its digits). E.g. { style: "percent" } or { style: "unit", unit: "millisecond" }.
measurestringNoneSets the name of the measure (first row).
captionstringNoneHidden caption that names the table for screen readers.
classNamestringNoneAdds extra classes to the outer element.

Keyboard

KeysAction
TabFocus the chart. It is one tab stop; the arrow keys then read it.
Arrow keysStep through the value, the target and each band.
Home/EndJump to the first / last stop.
EscapeClear the reading.

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

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .