React Gauge Component

2.0.28 · active · verified Tue Apr 21

react-gauge-component is a customizable React component designed for displaying gauge charts, often used for data visualization like speedometers or Grafana-style gauges. The current stable version is 2.0.28, with frequent patch and minor updates within the 2.x series. It was forked from `@Martin36/react-gauge-chart` and significantly re-architected in its v2 release to provide enhanced customization options and modern React compatibility. Key differentiators include robust TypeScript support, a flexible API for segment and value rendering, and an online sandbox editor for easy configuration. It requires React 16.8.2 or newer as a peer dependency, ensuring broad compatibility with contemporary React ecosystems.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates installing the package and rendering a basic gauge component with custom colored arcs, a value, and a formatted label.

import React from 'react';
import GaugeComponent from 'react-gauge-component';

function MyGauge() {
  return (
    <div style={{ width: '300px', height: 'auto' }}>
      <GaugeComponent
        arc={{
          width: 0.2,
          padding: 0.005,
          cornerRadius: 1,
          subArcs: [
            { limit: 15, color: '#EA4228', showPoint: true },
            { limit: 35, color: '#F5CD19', showPoint: true },
            { limit: 65, color: '#5BE12C', showPoint: true },
            { limit: 100, color: '#444444', showPoint: true }
          ]
        }}
        value={75}
        labels={{
          valueLabel: {
            formatTextValue: value => value + ' km/h'
          }
        }}
      />
    </div>
  );
}

export default MyGauge;

view raw JSON →