# Meter

Source: https://ecosphere.dev/docs/data/meter (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

One proportion, in the two shapes a dashboard needs: a 6px bar and a 92px ring.

`import { EcoMeter } from "vue-ecosphere"`

## Bar — in a row, beside its figure

Attendance at 61% is a warning; 61% of the syllabus covered in October is not. Use state only where it means something.

Vue (vue-ecosphere):

```vue
<EcoMeter :value="82" aria-label="Seats filled" />
<EcoMeter :value="94" state="ok" aria-label="Fees cleared" />
<EcoMeter :value="61" state="warn" aria-label="Papers set" />
<EcoMeter :value="28" state="bad" aria-label="Rooms mapped" />
```

React (react-ecosphere):

```tsx
<EcoMeter value={82} aria-label="Seats filled" />
<EcoMeter value={94} state="ok" aria-label="Fees cleared" />
<EcoMeter value={61} state="warn" aria-label="Papers set" />
<EcoMeter value={28} state="bad" aria-label="Rooms mapped" />
```

## Ring — leading a card

The ring is self-labelling: the figure sits in the middle.

Vue (vue-ecosphere):

```vue
<EcoMeter form="ring" :value="91" label="Attendance" />
<EcoMeter form="ring" :value="96" state="ok" label="Fees cleared" />
<EcoMeter form="ring" :value="64" state="warn" label="Papers set" />
<EcoMeter form="ring" :value="31" state="bad" label="Rooms mapped" />
```

React (react-ecosphere):

```tsx
<EcoMeter form="ring" value={91} label="Attendance" />
<EcoMeter form="ring" value={96} state="ok" label="Fees cleared" />
<EcoMeter form="ring" value={64} state="warn" label="Papers set" />
<EcoMeter form="ring" value={31} state="bad" label="Rooms mapped" />
```

## Bar inside a list row

Down a list, the bar keeps a fixed share of the row so every bar lines up.

Vue (vue-ecosphere):

```vue
<div class="lbr">
  <span class="lbr__b">
    <span id="g9d" class="lbr__n">Grade 9 · section D</span>
    <span class="lbr__h">38 of 42 seats</span>
  </span>
  <EcoMeter :value="90" aria-labelledby="g9d" />
</div>
```

React (react-ecosphere):

```tsx
<div className="lbr">
  <span className="lbr__b">
    <span id="g9d" className="lbr__n">Grade 9 · section D</span>
    <span className="lbr__h">38 of 42 seats</span>
  </span>
  <EcoMeter value={90} aria-labelledby="g9d" />
</div>
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number` | — | Required. The proportion, 0–100 (clamped). |
| `form` | `"bar" \| "ring"` | "bar" | Bar for one column of many; ring for a single figure leading a card. |
| `state` | `"ok" \| "warn" \| "bad"` | — | Colours the fill by state. Only where high and low genuinely mean good and bad. |
| `label` | `string` | — | Ring caption (eyebrow) below the figure. |
| `showValue` | `boolean` | true | The figure beside a bar. A bar alone shows the shape of a number nobody can read. |
| `aria-label / aria-labelledby` | `string` | — | Names the meter (role="meter", 0–100) for assistive tech. A ring is named by its label; give every bar one, or point it at the row's name. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number` | — | Required. The proportion, 0–100 (clamped). |
| `form` | `"bar" \| "ring"` | "bar" | Bar for one column of many; ring for a single figure leading a card. |
| `state` | `"ok" \| "warn" \| "bad"` | — | Colours the fill by state. Only where high and low genuinely mean good and bad. |
| `label` | `string` | — | Ring caption (eyebrow) below the figure. |
| `showValue` | `boolean` | true | The figure beside a bar. A bar alone shows the shape of a number nobody can read. |
| `aria-label / aria-labelledby` | `string` | — | Names the meter (role="meter", 0–100) for assistive tech. A ring is named by its label; give every bar one, or point it at the row's name. |
