

# Meter

A bar showing a scalar value inside a known range: disk usage, battery level, a password strength score. It is not [progress](/components/progress-bar): nothing is advancing toward completion, and the color says whether the value is good, not how far along it is.

It follows the HTML `<meter>` vocabulary: `value`, `min`, `max`, `low`, `high` and `optimum`.

## Examples

### Default

`min` is 0 and `max` is 100. `label` is the visible label and the accessible name; the formatted value sits beside it (hide it with `showValueText={false}`).

```tsx
import { Meter } from '@var-ui/react';

<Meter label="Storage used" value={42} />
```

```astro
---
import { Meter } from '@var-ui/astro';
---

<Meter label="Storage used" value={42} />
```

```html
<!-- No HTML demo yet: use @var-ui/react -->
```

### Thresholds

`low` and `high` split the range into three regions, and `optimum` says which one is best. The tone is derived the way browsers do for `<meter>`: a value in the optimum region is `success`, in the neighbouring region `warning`, and on the far side `danger`. With `optimum` high, as in the password strength example, the scale is reversed. Set `tone` to override the derived tone, and `valueLabel` to replace the value text.

```tsx
import { Meter, Stack } from '@var-ui/react';

<Stack gap="md">
  <Meter label="Disk usage" value={30} low={50} high={80} optimum={0} />
  <Meter label="Disk usage" value={65} low={50} high={80} optimum={0} />
  <Meter label="Disk usage" value={92} low={50} high={80} optimum={0} />
  <Meter label="Password strength" value={85} low={40} high={70} optimum={100} valueLabel="Strong" />
</Stack>
```

```astro
---
import { Meter } from '@var-ui/astro';
---

<Meter label="Disk usage" value={92} low={50} high={80} optimum={0} />
```

```html
<!-- No HTML demo yet: use @var-ui/react -->
```

### Sizes

`size` sets the track height: `sm`, `md` (default) or `lg`. `appearance="subtle"` softens the fill.

```tsx
import { Meter, Stack } from '@var-ui/react';

<Stack gap="md">
  <Meter label="Small" value={50} size="sm" />
  <Meter label="Medium" value={50} size="md" />
  <Meter label="Large" value={50} size="lg" tone="accent" />
</Stack>
```

```astro
<!-- No Astro demo for this variant: see the Astro peer in the page text -->
```

```html
<!-- No HTML demo yet: use @var-ui/react -->
```

## Meter or ProgressBar

| Use                                     | Component                                     |
| --------------------------------------- | --------------------------------------------- |
| An operation advances to completion     | [ProgressBar](/components/progress-bar)       |
| The same, in a ring                     | [ProgressCircle](/components/progress-circle) |
| A reading in a range, no task in flight | Meter                                         |

## Astro

`Meter` from `@var-ui/astro` renders the same DOM, classes and derived tone. It outputs `role="meter"`; the React component adds `progressbar` as a fallback (`meter progressbar`, React Aria's choice) for assistive technology that does not know `meter`.

## Props

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| value | number | yes |  | The measured value, clamped to `min`..`max`. |
| appearance | "solid" \| "subtle" \| undefined | no | "solid" |  |
| formatOptions | NumberFormatOptions \| undefined | no | `{ style: 'percent' }` | `Intl.NumberFormat` options for the value. |
| high | number \| undefined | no | max | Lower bound of the "high" region, as on `<meter>`. |
| label | string \| undefined | no |  | Visible label above the track; also the accessible name. |
| low | number \| undefined | no | min | Upper bound of the "low" region, as on `<meter>`. |
| max | number \| undefined | no | 100 |  |
| min | number \| undefined | no | 0 |  |
| optimum | number \| undefined | no | midpoint | The ideal value, as on `<meter>`. The tone is derived from where `value` sits relative to it. |
| showValueText | boolean \| undefined | no | true when `label` is set | Show the formatted value next to the label. A bare meter shows no value text. |
| size | "lg" \| "md" \| "sm" \| undefined | no | "md" |  |
| tone | "accent" \| "danger" \| "info" \| "neutral" \| "success" \| "warning" \| undefined | no | "success" |  |
| valueLabel | string \| undefined | no |  | Spoken and displayed value, replacing the formatted one. |

## Accessibility

- A `div` with `role="meter"` and `aria-valuemin`, `aria-valuemax`, `aria-valuenow` and `aria-valuetext`, built on React Aria's `Meter`. The native `<meter>` element is not used: its fill can only be styled through engine-specific pseudo-elements that differ between browsers.
- `aria-valuenow` is clamped to the range. ARIA has no `low`, `high` or `optimum`, so the good/bad judgement is visual: pair it with a `valueLabel` such as "Almost full" or "Strong" when the state matters.
- The tone is also available as `data-tone` for your own styling.
- Forced colors: the track gets a border and the fill uses `Highlight`, so the proportion stays readable.
- The meter is not focusable and has no keyboard interaction.


> Also accepts all standard HTML attributes (ARIA attributes, event handlers, styles, …). Run `var-ui component meter --all-props` for the complete list.
