Examples

Disk usage

Preview
Disk usage82%, Warning on a scale from 0% to 100%.
Warning
Example.tsx
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.

Preview
Net Promoter Score42, Good on a scale from -100 to 100.
Good
Example.tsx
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

Gauge props
PropTypeDefault
valuerequired
number—
min · max
number0 · 100
bands
Ranges read with the value.
{ to, label, color? }[]—
titlerequired
Names the figure.
string—
description
The takeaway; a factual summary is generated when omitted.
ReactNode—
table
The data table alternative.
'toggle' | 'visible' | 'none''toggle'
height · valueFormat · formatValue · messages
As 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.