<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-input-range-value/usage/ in the magma monorepo.
-->

# mds-input-range-value - examples

> The API of this component: [`AGENTS.md`](AGENTS.md).

Correct and idiomatic ways to use the `<mds-input-range-value>` component, ordered from most common to most specialized. The examples assume a working knowledge of the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md).

#### An Interval: Two Values

The canonical form: a minimum and a maximum on one track. The text of the range is its label, the text of each value names its thumb.

```html
<mds-input-range min="0" max="500" step="10" name="prezzo">
  Prezzo
  <mds-input-range-value value="100">Minimo</mds-input-range-value>
  <mds-input-range-value value="400">Massimo</mds-input-range-value>
</mds-input-range>
```

#### A Scale of Stops

More than two values: each stops at its neighbours, which it can reach but not pass. The header lists them, separated by a middle dot.

```html
<mds-input-range min="1" max="21" step="0.5" name="contrasto">
  Scala di contrasto
  <mds-input-range-value value="3">Passo 1</mds-input-range-value>
  <mds-input-range-value value="4.5">Passo 2</mds-input-range-value>
  <mds-input-range-value value="7">Passo 3</mds-input-range-value>
  <mds-input-range-value value="12">Passo 4</mds-input-range-value>
</mds-input-range>
```

#### Adding and Removing a Value

A value is an element: append a child to add a thumb, remove it to take the thumb away. The range emits `mdsInputRangeValuesChange` with the new list.

```html
<mds-input-range id="scala" min="0" max="100" name="passi">
  Passi
  <mds-input-range-value value="20"></mds-input-range-value>
  <mds-input-range-value value="80"></mds-input-range-value>
</mds-input-range>

<script>
  const scala = document.querySelector('#scala');
  const passo = document.createElement('mds-input-range-value');
  passo.value = 50;
  scala.append(passo); // a third thumb at 50
  passo.remove(); // back to two
</script>
```

#### Reading and Setting a Value

`value` follows its thumb, so the children are where the page reads the values; setting `value` moves the thumb, within its neighbours.

```js
const [minimo, massimo] = document.querySelectorAll('#prezzo mds-input-range-value');
console.log(minimo.value, massimo.value);
massimo.value = 300;
```
