Charts - Gauge
Use gauge charts to show a numeric value within a defined range as an arc or meter.
Overview
A gauge shows a numeric value within a defined range, often as an arc or needle against a scale. Use it for metrics like progress, capacity, or levels (for example, battery, storage, or completion).
The demo below shows basic gauge configurations.
Basics
Pass the current value with the value prop.
By default, the scale runs from 0 through 100.
Use valueMin and valueMax to set a different range.
Arc configuration
Use these props to change the arc shape:
startAngleandendAngle: angle range in degreesinnerRadiusandouterRadius: arc radii, as a pixel value or a percentage string (such as'50%')cornerRadius: corner rounding, as a pixel value or percentage string
import { Gauge } from '@mui/x-charts/Gauge';
<Gauge
value={75}
startAngle={0}
endAngle={360}
innerRadius="80%"
outerRadius="100%"
// ...
/>Playground
Text configuration
The gauge shows the value in the center of the arc by default.
Use the text prop to customize the center text.
Pass a string or a formatter function.
The formatter receives an object with value, valueMin, and valueMax.
Use the gaugeClasses.valueText class to change the text layout.
import { Gauge, gaugeClasses } from '@mui/x-charts/Gauge';
<Gauge
value={75}
startAngle={-110}
endAngle={110}
sx={{
[& .MuiGauge-valueText]: {
fontSize: 40,
transform: 'translate(0px, 0px)',
},
}}
text={({ value, valueMax }) => `${value} / ${valueMax}`}
/>Playground
Arc design
Use the gaugeClasses export for class names that target different parts of the gauge, such as valueText, valueArc, and referenceArc.
See Gauge—Classes for the full list.
Adding elements
Using the default Gauge
Add elements as children of Gauge to render them on top of the default arc and text.
import { Gauge } from '@mui/x-charts/Gauge';
<Gauge value={25} valueMax={50}>
<AddedElement />
</Gauge>;
Using the Gauge container
Use GaugeContainer and the following components when you need more control over the layout:
GaugeReferenceArc: the reference arcGaugeValueArc: the value arcGaugeValueText: the text in the center
import {
GaugeContainer,
Gauge,
GaugeReferenceArc,
GaugeValueArc,
} from '@mui/x-charts/Gauge';
<GaugeContainer value={25} valueMax={50}>
<GaugeReferenceArc />
<GaugeValueArc />
<AddedElement />
</GaugeContainer>;
Creating custom components
Use the useGaugeState() hook to build custom gauge components.
It returns:
- Value info:
value,valueMin,valueMax - Arc geometry:
startAngle,endAngle,outerRadius,innerRadius,cornerRadius,cx,cy - Computed:
maxRadius(largest radius that fits the drawing area) andvalueAngle(angle for the current value)
Accessibility
The gauge follows the Meter ARIA pattern.
The container has the meter role, and aria-valuenow, aria-valuemin, and aria-valuemax match the value range.
Label
If the gauge has a visible label, set aria-labelledby to point to it.
Otherwise, provide a label with aria-label.
Presentation
Assistive technologies often present the value as a percentage.
You can override this by setting the aria-valuetext attribute.
For example, a battery level indicator is clearer when it announces a duration (such as hours remaining) instead of only a percentage.
<h3 id="battery_level_label">
Battery level
</h3>
<Gauge
value={6}
valueMax={12}
aria-labelledby="battery_level_label"
aria-valuetext="50% (6 hours) remaining"
/>
Composition
Use GaugeContainer to supply the gauge parameters: value, valueMin, valueMax, startAngle, endAngle, and so on.
In addition to the shared chart components available for composition, you can use:
GaugeReferenceArc: the reference arcGaugeValueArc: the value arcGaugeValueText: the text in the center
Here's how the gauge is composed:
<GaugeContainer>
<GaugeReferenceArc />
<GaugeValueArc skipAnimation={skipAnimation} />
<GaugeValueText text={text} />
</GaugeContainer>
API
See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.