Charts
Gauge
A single value against its range as a half-circle meter, with optional bands such as OK, warning and critical.
import '@reactloom/charts/styles.css';
import { Gauge } from '@reactloom/charts';Examples
Disk usage
Warning
import { Gauge } from '@reactloom/charts';
export default function Example() {
return (
<div style={{ maxWidth: 320 }}>
<Gauge
title="Disk usage"
value={82}
valueFormat={{ style: 'unit', unit: 'percent' }}
bands={[
{ to: 70, label: 'OK', color: 'var(--pl-color-success-solid)' },
{ to: 90, label: 'Warning', color: 'var(--pl-color-warning-solid)' },
{ to: 100, label: 'Critical', color: 'var(--pl-color-danger-solid)' },
]}
/>
</div>
);
}Any range
Net Promoter Score from \u2212100 to 100.
Good
import { Gauge } from '@reactloom/charts';
// Any range: Net Promoter Score runs from −100 to 100.
export default function Example() {
return (
<div style={{ maxWidth: 320 }}>
<Gauge title="Net Promoter Score" value={42} min={-100} max={100} bands={[{ to: 0, label: 'Needs work' }, { to: 50, label: 'Good' }, { to: 100, label: 'Excellent' }]} />
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
valuerequired | number | — |
min · max | number | 0 · 100 |
bandsRanges read with the value. | { to, label, color? }[] | — |
titlerequiredNames the figure. | string | — |
descriptionThe takeaway; a factual summary is generated when omitted. | ReactNode | — |
tableThe data table alternative. | 'toggle' | 'visible' | 'none' | 'toggle' |
height · valueFormat · formatValue · messagesAs on the other charts. | | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
Theme tokens it reads
--pl-color-bg-muted --pl-color-chart-1 --pl-color-fg-default --pl-color-fg-muted --pl-font-size-sm
Accessibility
- The gauge is a meter (role="meter") with the value, range and band as text.
Usage guidelines
Do
- Use bands with words, so the state is not only a colour.
Don’t
- Don't put many gauges where a table of values would be easier to compare.