# Meter

A segmented gauge for a quantity within a known range, with warning and danger thresholds.

- Family: feedback
- Import: `import { Meter } from "@senvenli/react/feedback";`
- Page: https://design.senvenli.com/docs/components/meter
- JSON: https://design.senvenli.com/docs/components/meter.json

## Example: Usage against a limit

A value and its maximum, shown as “value / max”.

```tsx
import { Meter } from "@senvenli/react/feedback";

export default function Example() {
  return <Meter label="Seats" value={18} maxValue={50} />;
}
```

## Examples

### Warning and critical

Past a threshold the segments and the value text change color; the value label says it in words too.

```tsx
import { Meter } from "@senvenli/react/feedback";
import { Stack } from "@senvenli/react/layout";

const THRESHOLDS = { warning: 40, critical: 48 };

export default function Example() {
  return (
    <Stack space="space-300">
      <Meter label="Storage" value={22} maxValue={50} thresholds={THRESHOLDS} valueLabel="22 / 50 GB" />
      <Meter label="Storage" value={43} maxValue={50} thresholds={THRESHOLDS} valueLabel="43 / 50 GB · almost full" />
      <Meter label="Storage" value={49} maxValue={50} thresholds={THRESHOLDS} valueLabel="49 / 50 GB · full soon" />
    </Stack>
  );
}
```

### When low is bad

`badEnd="low"` warns as the value runs out.

```tsx
import { Meter } from "@senvenli/react/feedback";

export default function Example() {
  return (
    <Meter
      label="Email credits"
      value={150}
      maxValue={1200}
      segments={12}
      badEnd="low"
      thresholds={{ warning: 300, critical: 100 }}
      valueLabel="150 of 1,200 left · top up soon"
    />
  );
}
```

## Guidelines

### When to use it

- Showing how much of a limit is used: storage, seats, quota.

### Use something else when

- [progress](https://design.senvenli.com/docs/components/progress.md): The value is a task's progress.
- [gauge-chart](https://design.senvenli.com/docs/components/gauge-chart.md): One headline value on a dashboard reads better as a half ring with a target.

## Accessibility

Built in:

- Exposed as a meter with its value text.

You provide:

- A `label` and a value label in real units.

## API reference

### Meter

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| label | `React.ReactNode` |  | yes |  |
| value | `number` |  | yes |  |
| maxValue | `number` |  | yes |  |
| badEnd | `"high" \| "low"` | `"high"` | no | Which end is the bad one: `high` (quota, usage; default) warns as the value grows, `low` (fuel, credit left) warns as it shrinks. |
| segments | `number` | `10` | no | Segments in the track: 10, or the real unit count (8 for fuel eighths). |
| thresholds | `MeterThresholds` |  | no |  |
| valueLabel | `string` |  | no | "38 / 50", "460 / 500 · 92%", "1/8 · refill soon": the state in words too, never colour alone. Defaults to "value / max". |

### Tokens it reads

`--ds-background-neutral`, `--ds-chart-1`, `--ds-icon-danger`, `--ds-icon-warning`, `--ds-radius-xsmall`, `--ds-space-075`, `--ds-space-200`, `--ds-text-danger`, `--ds-text-subtlest`, `--ds-text-warning`

## Related

- [progress](https://design.senvenli.com/docs/components/progress.md)
