Gauge chart components for the Tremor design system. Pure SVG rendering with zero charting dependencies.
Live Examples | npm | GitHub
GaugeChart— Single-value arc gauge with optional needle, thresholds, and gradient fillsGaugeMulti— Multi-segment gauge with interactive segments and tooltipsGaugeLegend— Legend companion with colored indicators, values, and share badges
npm install tremor-gaugePeer dependencies: react and react-dom (18 or 19).
Add the library to your Tailwind content config so its classes are included:
// tailwind.config.js
module.exports = {
content: [
"./src/**/*.{js,ts,jsx,tsx}",
"./node_modules/tremor-gauge/dist/**/*.{js,cjs}",
],
darkMode: "class",
};Dark mode is supported via Tailwind's class strategy.
import { GaugeChart, GaugeMulti, GaugeLegend } from "tremor-gauge";<GaugeChart
value={72}
color="blue"
label="Performance"
showNeedle
arcSpan={240}
valueFormatter={(v) => `${v}%`}
/><GaugeChart
value={67}
min={20}
max={100}
showNeedle
arcSpan={270}
thresholds={[
{ value: 20, color: "emerald" },
{ value: 70, color: "amber" },
{ value: 85, color: "pink" },
]}
showThresholdArc="bands"
/><GaugeChart
value={92}
gradient={{ from: "cyan", to: "blue" }}
label="Score"
strokeWidth={14}
/>const [active, setActive] = useState<string | undefined>();
const data = [
{ name: "Sales", amount: 450 },
{ name: "Returns", amount: 120 },
];
const colors = ["blue", "emerald"];
const items = data.map((d, i) => ({
name: d.name,
value: d.amount,
color: colors[i],
}));
<GaugeMulti
data={data}
category="name"
value="amount"
colors={colors}
label="Total"
activeName={active}
onValueChange={(d) => setActive(d ? d.name : undefined)}
/>
<GaugeLegend
items={items}
showShare
activeName={active}
onItemClick={(name) => setActive(active === name ? undefined : name)}
/>Clicking a segment highlights the matching legend item and vice versa.
| Prop | Type | Default | Description |
|---|---|---|---|
value |
number |
required | Current value |
min |
number |
0 |
Minimum value |
max |
number |
100 |
Maximum value |
color |
Color |
"blue" |
Tremor color token (ignored when thresholds or gradient is set) |
thresholds |
GaugeThreshold[] |
— | Value-based color zones (see below) |
showThresholdArc |
boolean | "bands" | "ticks" |
false |
Visualise threshold zones on the track |
gradient |
{ from: Color; to: Color } |
— | Gradient fill across the arc |
valueFormatter |
(v: number) => string |
String |
Format the center value label |
showLabel |
boolean |
true |
Show center value label |
label |
string |
— | Secondary label text below the value |
showMinMax |
boolean |
false |
Show min/max labels at arc ends |
showAnimation |
boolean |
true |
Animate arc and needle on mount |
arcSpan |
180 | 240 | 270 |
180 |
Arc span in degrees |
showNeedle |
boolean |
false |
Show needle indicator |
strokeWidth |
number |
10 |
Arc stroke width |
className |
string |
— | Additional CSS class |
{ value: number; color: Color }Each entry defines a zone starting at value. The fill color changes to the highest threshold the current value has reached.
| Prop | Type | Default | Description |
|---|---|---|---|
data |
object[] |
required | Data array |
category |
string |
required | Key for category labels |
value |
string |
required | Key for numeric values |
colors |
Color[] |
all colors | Color tokens per segment |
label |
string |
— | Center label text |
showTooltip |
boolean |
true |
Show tooltip on hover |
onValueChange |
(datum | null) => void |
— | Segment click callback |
activeName |
string |
— | Externally controlled highlighted segment name |
customTooltip |
(props) => ReactNode |
— | Custom tooltip renderer |
valueFormatter |
(v: number) => string |
String |
Format values in tooltip and center label |
marker |
{ value, label? } |
— | Marker line on the arc |
arcSpan |
180 | 240 | 270 |
180 |
Arc span in degrees |
strokeWidth |
number |
12 |
Arc stroke width |
showAnimation |
boolean |
true |
Animate segments on mount |
className |
string |
— | Additional CSS class |
| Prop | Type | Default | Description |
|---|---|---|---|
items |
GaugeLegendItem[] |
required | Legend items |
valueFormatter |
(v: number) => string |
String |
Format values |
showShare |
boolean |
false |
Show percentage share badge |
activeName |
string |
— | Highlighted item name |
onItemClick |
(name: string) => void |
— | Item click callback |
className |
string |
— | Additional CSS class |
9 Tremor-compatible tokens: blue, emerald, violet, amber, gray, cyan, pink, lime, fuchsia (all at 500 shade).
- Pure SVG via
<circle>stroke-dasharray — no canvas, no charting library - Animate on mount with CSS transitions (respects
prefers-reduced-motion) - Dark mode via Tailwind
dark:classes - Accessible:
role="meter"witharia-valuenow/min/max "use client"directive for Next.js App Router compatibility- Fluid sizing via SVG
viewBox— control width withclassName
npm install
npm test # Run Vitest tests
npm run build # Build ESM + CJS + types
npm run storybook # Interactive component demos
npm run typecheck # TypeScript checkApache-2.0