<!-- generated by scripts/gen-docs.mjs from docs/system/slider.md. Edit the source and rerun. -->
# Slider

## Description
Sets a number, or a low and a high bound, by its place along a scale, and lets the bounds of a range be typed exactly.

`import { RangeField, rangeFieldLabels, Slider, sliderLabels, SliderValue } from "@/components/cobalt/ui/slider"`, source `registry/cobalt/ui/slider.tsx`, status `ready-with-gaps`.
Foundation: `Base UI Slider`. Traps checked: `trap/control-height`, `trap/field-label`, `trap/label-unbound`, `trap/field-input-type`, `trap/field-error-link`, `trap/field-error-timing`, `trap/field-keeps-input`, `trap/touch-input-zoom`, `trap/focus-ring-shape`, `trap/select-empty-value`, `trap/gesture-drag`, `trap/gesture-axes`, `trap/motion-input-lag`, `trap/numbers-shift`, `trap/live-region-double`, `trap/open-trigger-unfocused`, `trap/overlay-focus-return`, `trap/disabled-drops-focus`, `trap/weight-shift`, `trap/tooltip-essential`, `trap/touch-hover-flash`, `trap/reduced-motion-ignored`, `trap/motion-transition-all`.

The range filter is on this page too: `import { RangeFilter, rangeFilterLabels } from "@/components/cobalt/ui/range-filter"` (source `registry/cobalt/ui/range-filter.tsx`), a pill for a filter row that opens a `RangeField`. Both read and write their figures through `import { describeRange, formatAmount, parseAmount, rangeWords, sameRange, type Bound, type Range } from "@/lib/cobalt/range"` (source `registry/cobalt/lib/range.ts`), which has no DOM: it reads "50M", "$1.2B" and "25%" in the field's locale, writes a bound back, and places a value on a linear or a log track.

`trap/control-height` is answered by the 36px control, which lines the track up with the fields under it, and by the filter pill at `--control-sm`, the height of FilterBar's pills (Tokens). `trap/field-label` and `trap/label-unbound` by the visible Minimum and Maximum labels bound with `htmlFor`, and the thumbs named from `aria-label` (ARIA). `trap/field-input-type` by `inputMode="decimal"` and `autoComplete="off"` on both fields (ARIA). `trap/field-error-link` by `aria-invalid` and `aria-describedby` on the line under the fields (ARIA). `trap/field-error-timing` by reading a typed bound only when its field is left or Enter is pressed (States). `trap/field-keeps-input` by a refused field keeping the words typed (States). `trap/touch-input-zoom` by the Input's 16px text below 768px (Tokens). `trap/focus-ring-shape` by the round thumb's outline after Tab (States). `trap/select-empty-value` by the open end: an empty field, a thumb dragged all the way out, or `Clear` in the filter (States). `trap/gesture-drag` by Base UI's thumb drag (Foundation). `trap/gesture-axes` by `touch-none` on the control and `data-base-ui-swipe-ignore`, so inside a bottom sheet a drag moves the thumb and never the sheet (Foundation). `trap/motion-input-lag` by the thumb and the fill moving with no transition (Motion). `trap/numbers-shift` by tabular figures in `SliderValue`, the fields and the pill (Tokens). `trap/live-region-double` by one live line under the fields, while `SliderValue` is an `output` with `aria-live="off"` (ARIA). `trap/open-trigger-unfocused` by the pill's fill while `aria-expanded` (States). `trap/overlay-focus-return` by Escape returning focus to the pill, and `trap/disabled-drops-focus` by `Clear`, which is never disabled, so pressing it keeps the focus (Keyboard). `trap/weight-shift` by the pill's `font-medium` when on and off. `trap/tooltip-essential` by the cut pill's tooltip, which repeats words the pill's `aria-label` and the open popover also hold (States). `trap/touch-hover-flash` by the system's `hover` variant, which applies only under `(hover: hover)`. `trap/reduced-motion-ignored` and `trap/motion-transition-all` by opacity and colour fades that name their properties, and the sheet's slide dropping to a fade (Motion).

A range that filters a list beside other filters is one of FilterBar's own `filters`, with `type: "range"` (`docs/system/examples/slider/in-filter-bar.tsx:25`): the row shows it as a `RangeFilter` pill, the phone's Filters sheet holds its track and fields, the bar counts a set range as one, and Clear resets it to `[null, null]` with the rest (`registry/cobalt/ui/filter-bar.tsx:311`, `registry/cobalt/ui/filter-bar.tsx:316`).

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| Base UI `Slider`: the root, control, track, indicator, thumb and value parts; a range input per thumb that a form and a screen reader read; a drag that follows the pointer; a press on the track that moves the nearest thumb there; the arrow keys, Shift, Page Up, Page Down, Home and End; `onValueChange` on every step and `onValueCommitted` when a thumb is let go; `getAriaValueText`; thumbs that never pass each other, where a drag pushes the other thumb along and a key stops at it | The look: a 36px control, a 6px track in `--muted` with the chosen part in the accent, 20px round thumbs in the card's white with the raised shadow, held inside the track's ends (`thumbAlignment="edge"`). Thumb names from `aria-label`, with "Minimum" and "Maximum" added for a range. `touch-none` and `data-base-ui-swipe-ignore` for a slider inside a sheet. `SliderValue` in tabular figures. `RangeField`: two typed fields read as amounts when left or confirmed, a log track run on twenty stops a decade with values kept to two significant figures, an empty field or a thumb at the track's end as an open end, and one line under the fields that says what they take or why a figure was refused. `RangeFilter`: a pill that reads its name, then the name and the range, cut at the row's width with the whole of it in a tooltip under the pointer, opening the field in a popover or, below 640px, a sheet, with presets and `Clear`; the pill changes once a change is finished |

## Examples
A match threshold from 50 to 100 percent, with its figure beside the label changing in place as the thumb moves.

Real uses, 0 call sites (`rg -n "<Slider\b" app registry --glob '!registry/cobalt/ui/*'`): no showcase page draws one outside its examples, and the examples folder does not count.

Uses inside the registry:

- The image field's crop dialog: zoom from 1 to 3 on a single thumb, read as a percentage, `registry/cobalt/ui/image-field.tsx:763-768`.
- `RangeField` draws its track with `Slider`, `registry/cobalt/ui/slider.tsx:316`.
- `RangeFilter` opens a `RangeField` in its popover, `registry/cobalt/ui/range-filter.tsx:122`.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/slider/default.tsx` | default | A match threshold from 50 to 100 percent; the figure beside the label changes in place as the thumb moves, and the arrow keys step by 1 |
| `docs/system/examples/slider/range.tsx` | scale=linear | Fund age from 0 to 40 years on a linear track with two thumbs; a thumb dragged all the way out empties its field, for no limit |
| `docs/system/examples/slider/log-scale.tsx` | scale=log | Assets from $1M to $1T on a log track, so each tenfold step takes the same room; 250M or 1.2B typed in a field sets a bound exactly |
| `docs/system/examples/slider/default.tsx` | orientation=horizontal | The default track across the width, here a match threshold |
| Not applicable: the two axes belong to different parts, `scale` to `RangeField` and `RangeFilter` and `orientation` to `Slider`, and `RangeField` draws only a horizontal track | matrix:scale,orientation | No part takes both |
| `docs/system/examples/slider/vertical.tsx` | orientation=vertical | Zoom on a venue's photo, as a track standing along the photo's edge; up zooms in, the figure above the track says how far, and the arrow keys step by 10 percent |
| `docs/system/examples/slider/in-filter-bar.tsx` | composition:FilterBar | Assets as one more filter in a screener's row; its pill reads the range once one is set, a phone counts it in the Filters sheet with the rest, and Clear clears it with them |

Example: A match threshold from 50 to 100 percent; the figure beside the label changes in place as the thumb moves, and the arrow keys step by 1 (`docs/system/examples/slider/default.tsx`)

```tsx
import { useState } from "react";

import { Slider, SliderValue } from "@/components/cobalt/ui/slider";

export default function Example() {
  const [score, setScore] = useState(80);
  return (
    <div className="w-full max-w-sm">
      <Slider
        aria-label="Match threshold"
        value={score}
        onValueChange={setScore}
        min={50}
        max={100}
        format={{ style: "unit", unit: "percent" }}
      >
        <div className="flex items-baseline justify-between gap-3 text-sm">
          <span className="font-medium">Match threshold</span>
          <SliderValue />
        </div>
      </Slider>
    </div>
  );
}
```

Example: Assets as one more filter in a screener's row; its pill reads the range once one is set, a phone counts it in the Filters sheet with the rest, and Clear clears it with them (`docs/system/examples/slider/in-filter-bar.tsx`)

```tsx
import { useState } from "react";

import { type Filter, FilterBar } from "@/components/cobalt/ui/filter-bar";
import type { Bound } from "@/lib/cobalt/range";

// Inert sample data: invented funds and their assets in dollars.
const funds = [
  { name: "Harbour Large Cap Core", type: "Hedge fund", assets: 4.2e9 },
  { name: "Calder Global Equity", type: "Hedge fund", assets: 860e6 },
  { name: "Northgate Short Duration", type: "Private credit", assets: 12.5e9 },
  { name: "Pryor Dean Real Assets", type: "Real estate", assets: 310e6 },
  { name: "Ashby Wren Growth", type: "Private equity", assets: 2.1e9 },
  { name: "Hollis Crane Income", type: "Private credit", assets: 48e6 },
];

export default function Example() {
  const [types, setTypes] = useState<string[]>([]);
  const [assets, setAssets] = useState<[Bound, Bound]>([1e9, null]);
  const inRange = (value: number) => (assets[0] === null || value >= assets[0]) && (assets[1] === null || value <= assets[1]);
  const shown = funds.filter((f) => (types.length === 0 || types.includes(f.type)) && inRange(f.assets));
  const filters: Filter[] = [
    {
      key: "assets",
      type: "range",
      label: "Assets",
      value: assets,
      onValueChange: setAssets,
      min: 1e6,
      max: 1e12,
      scale: "log",
      kind: "money",
      presets: [
        { label: "$100M or more", value: [1e8, null] },
        { label: "$1B or more", value: [1e9, null] },
        { label: "$10B or more", value: [1e10, null] },
      ],
    },
    {
      key: "type",
      label: "Type",
      options: [...new Set(funds.map((f) => f.type))].map((value) => ({ value, label: value })),
      value: types,
      onValueChange: setTypes,
    },
  ];
  return (
    <div className="flex w-full flex-col gap-3">
      <FilterBar filters={filters} done={`Show ${shown.length} funds`} />
      <p className="text-sm text-muted-foreground">
        <span className="font-medium text-foreground tabular-nums">{shown.length}</span> funds
      </p>
    </div>
  );
}
```

## Variants

### scale
- `linear`: the default, for a range within one order of magnitude, such as a fund's age from 0 to 40 years; `step` sets the stops and `largeStep` is a tenth of the track. Used at 0 call sites.
- `log`: for a spread over several orders of magnitude, such as assets from $1M to $1T; each tenfold step takes the same width, the track has twenty stops a decade, and a dragged value keeps two significant figures, so it lands on $1.2B and never on $1,187,356,201. It needs `min` above 0. Used at 0 call sites.

`scale` is a prop of `RangeField` and `RangeFilter`. `Slider` itself places its values on a linear track.

Example: Fund age from 0 to 40 years on a linear track with two thumbs; a thumb dragged all the way out empties its field, for no limit (`docs/system/examples/slider/range.tsx`)

```tsx
import { useState } from "react";

import { RangeField } from "@/components/cobalt/ui/slider";
import type { Bound } from "@/lib/cobalt/range";

export default function Example() {
  const [age, setAge] = useState<[Bound, Bound]>([5, 20]);
  return (
    <RangeField
      label="Fund age, in years"
      value={age}
      onValueChange={setAge}
      min={0}
      max={40}
      className="w-full max-w-xs"
    />
  );
}
```

Example: Assets from $1M to $1T on a log track, so each tenfold step takes the same room; 250M or 1.2B typed in a field sets a bound exactly (`docs/system/examples/slider/log-scale.tsx`)

```tsx
import { useState } from "react";

import { RangeField } from "@/components/cobalt/ui/slider";
import { describeRange, type Bound } from "@/lib/cobalt/range";

export default function Example() {
  const [assets, setAssets] = useState<[Bound, Bound]>([1e9, 5e10]);
  return (
    <div className="flex w-full max-w-xs flex-col gap-4">
      <RangeField
        label="Assets under management"
        value={assets}
        onValueChange={setAssets}
        min={1e6}
        max={1e12}
        scale="log"
        kind="money"
      />
      <p className="text-sm">
        Funds with <span className="tabular-nums">{describeRange(assets, { kind: "money" })}</span> in assets
      </p>
    </div>
  );
}
```

### orientation
- `horizontal`: the default, a track across the width, lined up with the fields beside and under it. Used at 3 call sites: the image field's zoom, `RangeField` and, through it, `RangeFilter`.
- `vertical`: a track standing in a column a control wide, for a value set along the edge of what it changes, such as zoom beside a photo. It fills the height its host gives it. Used at 0 call sites.

Example: The default track across the width, here a match threshold (`docs/system/examples/slider/default.tsx`)

```tsx
import { useState } from "react";

import { Slider, SliderValue } from "@/components/cobalt/ui/slider";

export default function Example() {
  const [score, setScore] = useState(80);
  return (
    <div className="w-full max-w-sm">
      <Slider
        aria-label="Match threshold"
        value={score}
        onValueChange={setScore}
        min={50}
        max={100}
        format={{ style: "unit", unit: "percent" }}
      >
        <div className="flex items-baseline justify-between gap-3 text-sm">
          <span className="font-medium">Match threshold</span>
          <SliderValue />
        </div>
      </Slider>
    </div>
  );
}
```

Example: Zoom on a venue's photo, as a track standing along the photo's edge; up zooms in, the figure above the track says how far, and the arrow keys step by 10 percent (`docs/system/examples/slider/vertical.tsx`)

```tsx
import { useState } from "react";

import { Slider, SliderValue } from "@/components/cobalt/ui/slider";

export default function Example() {
  const [zoom, setZoom] = useState(100);
  return (
    <div className="flex h-56 w-full max-w-md gap-3">
      <div className="image-outline relative min-w-0 flex-1 overflow-hidden rounded-2xl bg-muted">
        <img
          src="/photos/city-london.webp"
          alt="The terrace of the venue, over the river"
          draggable={false}
          // The photo is drawn larger about its centre, so the frame shows less of it.
          style={{ width: `${zoom}%`, height: `${zoom}%`, left: `${(100 - zoom) / 2}%`, top: `${(100 - zoom) / 2}%` }}
          className="absolute max-w-none object-cover"
        />
      </div>
      <Slider
        aria-label="Zoom"
        orientation="vertical"
        value={zoom}
        onValueChange={setZoom}
        min={100}
        max={300}
        step={10}
        format={{ style: "unit", unit: "percent" }}
      >
        <SliderValue className="text-xs" />
      </Slider>
    </div>
  );
}
```

## States
The parts send no request of their own, so they have no pending, success or failure: the host loads its list from `onValueCommitted`, or from `RangeFilter`'s `onValueChange`, which hears only finished changes.

| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| vertical | `orientation="vertical"` | drag the thumb up or down, press the track, Up and Down | the same parts stood up: the fill rising from the bottom, `aria-orientation="vertical"` on each thumb | test |
| idle | rendered with a value | drag a thumb, press the track, Tab to a thumb, type a bound | each thumb's place, the fill between the ends, the figure in `SliderValue` or in the fields | test |
| hover | the pointer over the filter pill, under `(hover: hover)` | press it | pointer only, colour change: the grey fill steps to `--muted-hover`, or the ink to 85 percent when on; the thumb has no hover look | by hand |
| focus-visible | Tab onto a thumb | step with the keys | the system's 2px outline around the round thumb, 2px from it | by hand |
| dragging | a pointer down on a thumb, or a press on the track, which moves the nearest thumb there | move the thumb; dragged into the other, it pushes it along (measured: the low thumb dragged to 33 took the high one from 20 to 33) | the thumb under the pointer, the fill, and in `RangeField` both fields rewritten as it moves | by hand |
| open end | a bound is `null` | type a figure, or drag the thumb in | an empty field with "No minimum" or "No maximum", and its thumb at the track's end | test |
| past the track | a bound beyond `min` or `max`, typed or passed in | drag the thumb back in | the figure in its field, and its thumb waiting at the end it passed | test |
| editing | a field has focus and is typed in | type, then leave the field or press Enter | the words typed; no thumb moves until the field is left or Enter is pressed (measured: "12" typed in the low field left its thumb at 5 until Enter) | by hand |
| not a number | a field left, or Enter pressed, holding words that do not read as a number | retype, or drag a thumb | the field keeps the words, with `aria-invalid` and the red wash; the line under the fields reads "Not a number", or for money "Not an amount. Try 250M or 1.2B" | by hand |
| out of order | a typed bound passes the other bound | retype, or drag a thumb | the field keeps the words, with `aria-invalid`; the line reads "The minimum is above the maximum" or "The maximum is below the minimum", and the range does not change | by hand |
| disabled | `disabled` | nothing | half opacity, a not-allowed cursor on the track, and disabled range inputs and fields | by hand |
| filter off | `RangeFilter`'s `value` is `[null, null]` | open it | the pill reads its `label` in the grey fill | test |
| filter on | either bound is set | open it, or press `Clear` inside | the pill reads the name and the range in words, such as "Assets $1B or more", in the ink fill, and says the same as its `aria-label`; cut at the row's width, it shows the whole in a tooltip under the pointer (measured on the stress page at 320) | test |
| filter open | the pill is pressed | drag, type, press a preset or `Clear`, press Escape | a popover named by `label` under the pill, or below 640px a sheet with `label` as its title; the pill keeps `aria-expanded` and its pressed fill | by hand |
| preset on | the range in the popover equals a preset | press it again to remove the range | the preset's ink fill and `aria-pressed` | by hand |

### State precedence
- Dragging and not a number, or dragging and out of order: dragging wins. A drag clears the refused words and the reason, and writes both fields from the thumbs.
- Not a number and out of order: not a number wins in the line, "Not a number", while each refused field keeps `aria-invalid`.
- Editing and open end: both show. The placeholder stays while the focused field is empty.
- Focus-visible and dragging: both show.
- Disabled and focus-visible: Not applicable: a disabled slider's range inputs are disabled and leave the tab order.
- Filter on and filter open: both show. The pill keeps the finished range while the thumbs and the fields follow a drag, and changes once the change is finished, so the pills after it do not move during a drag.
- Preset on and dragging: dragging wins. The preset turns off as soon as the range in the popover leaves its value.
- Past the track and dragging: dragging wins. A drag from the end writes a value inside the track.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| a thumb follows the pointer or a key | input | none: Base UI places the thumb and the fill on each move, with no transition | the thumb's inline start and the fill's width | the same, since nothing eases |
| the line under the fields turns to a reason and back | announce | `TextSwap`: the old words leave on 70 percent of `--t-pop`, the new arrive on `--t-icon`; the colour changes on `--t-press` | opacity, color | the same fade |
| the filter's popover opens or closes | announce | `popup-motion`, `--t-pop` on `--curve`, leaving on 70 percent of it | opacity | the same fade |
| below 640px, the filter's sheet opens or closes | announce | the Sheet's slide from the bottom on `--t-sheet` and `--curve-sheet`, leaving on `--t-leave` | translate, opacity | a fade on `--t-fade`, with no slide |

## Props

<!-- Props generated from registry/cobalt/ui/slider.tsx, registry/cobalt/ui/range-filter.tsx with TypeScript by scripts/props-table.mjs -->
### Slider

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `aria-label?` | `string` |  | Defines a string value that labels the current element. |
| `children?` | `ReactNode` |  | Shown above the track, such as a label and a `SliderValue`. |
| `className?` | `string` |  |  |
| `getAriaValueText?` | `(formattedValue: string, value: number, index: number) => string` |  | The words a screen reader hears for a value, such as "$1.2B" for a position on a log track. |
| `labels?` | `Partial<{ minimum: string; maximum: string; }>` |  |  |

Also accepts every native `<div>` attribute; from Base UI: `defaultValue`, `disabled`, `form`, `format`, `largeStep`, `locale`, `max`, `min`, `minStepsBetweenValues`, `name`, `onValueChange`, `onValueCommitted`, `orientation`, `step`, `thumbCollisionBehavior`, `value`.

### SliderValue

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `className?` | `string \| (((state: SliderValueState) => string) & string)` |  | CSS class applied to the element, or a function that returns a class based on the component's state. |

Also accepts every native `<output>` attribute; from Base UI: `render`.

### RangeField

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `max` | `number` |  |  |
| `min` | `number` |  | The track's ends. |
| `onValueChange` | `(value: [Bound, Bound]) => void` |  | Every step of a drag, and a typed bound once its field is left or confirmed with Enter. |
| `value` | `Range` |  | The range: a low and a high bound, either of which may be `null` for an open end. |
| `className?` | `string` |  |  |
| `currency?` | `string` | `"USD"` |  |
| `disabled?` | `boolean` | `false` |  |
| `kind?` | `AmountKind` | `"number"` | How the bounds are written: a number, money or a percentage. |
| `label?` | `string` |  | The range's name, such as "Assets under management", for the track and both fields. |
| `labels?` | `Partial<{ minimum: string; maximum: string; noMinimum: string; noMaximum: string; hint: (kind: AmountKind) => "Type an amount, such as 250M or 1.2B" \| "Type a percentage" \| "Type a number"; aboveMaximum: string; belowMinimum: string; invalid: (kind: AmountKind) => "Not an amount. Try 250M or 1.2B" \| "Not a percentage" \| "Not a number"; }>` |  |  |
| `locale?` | `string` | `"en-US"` |  |
| `onValueCommitted?` | `(value: [Bound, Bound]) => void` |  | A change the person has finished: a thumb let go, or a field left or confirmed with Enter. |
| `scale?` | `Scale` | `"linear"` | `log` for a spread over several orders of magnitude, such as assets from $1M to $1T. |
| `step?` | `number` | `1` | A linear track's step. |

### RangeFilter

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `label` | `string` |  | The filter's name: "Assets". |
| `max` | `number` |  |  |
| `min` | `number` |  |  |
| `onValueChange` | `(value: [Bound, Bound]) => void` |  | The finished range: a thumb let go, a field left or confirmed, a preset, or Clear. |
| `value` | `Range` |  | The range the list is filtered by. |
| `className?` | `string` |  |  |
| `currency?` | `string` | `"USD"` |  |
| `kind?` | `AmountKind` | `"number"` |  |
| `labels?` | `Partial<Omit<{ summary: (label: string, range: string) => string; clear: string; presets: string; words: { atMost: (high: string) => string; between: (low: string, high: string) => string; atLeast: (low: string) => string; any: string; }; minimum: string; maximum: string; noMinimum: string; noMaximum: string; hint: (kind: AmountKind) => "Type an amount, such as 250M or 1.2B" \| "Type a percentage" \| "Type a number"; aboveMaximum: string; belowMinimum: string; invalid: (kind: AmountKind) => "Not an amount. Try 250M or 1.2B" \| "Not a percentage" \| "Not a number"; }, "words">> & { words?: Partial<{ between: (low: string, high: string) => string; atLeast: (low: string) => string; atMost: (high: string) => string; any: string; }>; }` |  |  |
| `locale?` | `string` | `"en-US"` |  |
| `presets?` | `{ label: string; value: Range; }[]` | `[]` | Ranges people pick most, as pills under the fields, such as "$1B or more". |
| `scale?` | `Scale` |  | `linear` the default; `log` for a spread over several orders of magnitude. |
| `step?` | `number` |  |  |

`Slider` takes Base UI's root props: `value` or `defaultValue`, a number for one thumb or a pair for a range, `min`, `max`, `step`, `largeStep`, `format`, `locale`, `onValueChange`, `onValueCommitted`, `disabled` and `name`. `aria-label` names the thumbs, and `labels` replaces "Minimum" and "Maximum". `getAriaValueText` sets what a screen reader hears for a value. `children` sit above the track, such as a label and a `SliderValue`. `orientation="vertical"` stands the same parts up from Base UI's `data-orientation`: a column `--control` wide, 36px, whose 6px track fills the height the host gives it, 128px at least, filled from the bottom in the accent, with the thumbs held inside its ends and the children above it; Up and Right step up. Measured on `vertical.tsx` at 1440 light and at 390 dark with Pill corners: the control 36 by 204px, the track 6px and fully round in both corner modes, the thumb 20px at the bottom end at the minimum and at the top end after a drag past it, Up twice moving it 18px from 100 to 120 percent, and the thumb's outline after Tab.

`RangeField` takes `value`, a pair of bounds where `null` is an open end. `onValueChange` hears every step of a drag and a typed bound once its field is left or confirmed; `onValueCommitted` hears only finished changes. `min` and `max` are the track's ends, `step` the stops of a linear track, `scale` its kind, `kind` how bounds are written (`number`, `money` or `percent`), with `currency` and `locale`. `label` names the group, the track and both fields. `disabled` and `labels` complete it. `scale="log"` with a `min` of 0 or below falls back to a linear track without a warning.

`RangeFilter` takes `label`, `value`, `min`, `max`, `step`, `scale`, `kind`, `currency`, `locale`, `presets` (each a `label` and a `value`) and `labels`, where `labels.words` replaces the words of a range. Its `onValueChange` hears only finished ranges: a thumb let go, a field left or confirmed, a preset, or `Clear`.

## Usage

### When to use
- A number whose place on a known scale matters more than its exact figure, such as how close a name must be to count as a match.
- A range of numbers that people set roughly and sometimes exactly, such as a fund's assets or its age.
- A numeric filter in a filter row over a list, as one more pill beside the others.

### When not to use
- An exact number with no scale to place it on, such as a quantity. Use NumberField instead.
- One of a few named settings, such as daily or weekly. Use SegmentedControl instead.
- A filter over named choices, such as a fund's type. Use FilterBar instead.
- A range of dates. Use DatePicker instead.

### Rules
- `rule/slider-filter-on-commit`: When a range filters a list or sends a request, send it from `onValueCommitted`, or from `RangeFilter`'s `onValueChange`, instead of from `RangeField`'s `onValueChange`, because `onValueChange` fires on every step of a drag and a request per step floods the server. Evidence: principle input: a drag reports every pointer move, and only the release is a decision; single use `docs/system/examples/slider/in-filter-bar.tsx:28`, where the list follows `RangeFilter`'s finished ranges. Check: review of every `RangeField` whose `onValueChange` fetches.
  - Don't: `<RangeField label="Assets" value={assets} onValueChange={(next) => { setAssets(next); refetch(next); }} min={1e6} max={1e12} />`
  - Do: `<RangeField label="Assets" value={assets} onValueChange={setAssets} onValueCommitted={refetch} min={1e6} max={1e12} />`
- `rule/slider-log-above-zero`: When passing `scale="log"`, set `min` above 0, such as 1e6 for assets, instead of 0, because a log track with a `min` of 0 or below falls back to a linear track and says nothing. Evidence: principle heuristic: error prevention, `registry/cobalt/ui/slider.tsx:230` turns a log track whose `min` is 0 or below into a linear one without a warning. Check: review of every `scale="log"`.
  - Don't: `<RangeField label="Assets" value={assets} onValueChange={setAssets} min={0} max={1e12} scale="log" kind="money" />`
  - Do: `<RangeField label="Assets" value={assets} onValueChange={setAssets} min={1e6} max={1e12} scale="log" kind="money" />`
- `rule/slider-name-the-thumbs`: When a `Slider` has no `FieldLabel` bound to it, pass `aria-label` with what it sets, such as "Match threshold", instead of a visible label alone, because each thumb is its own range input and a text beside it does not name it; a range then names its thumbs "Match threshold, Minimum" and "Match threshold, Maximum". Evidence: principle wcag: 4.1.2 Name, role, value, every input has a name. Check: test `slider.test.tsx` expects each thumb's `aria-label`.
  - Don't: `<Slider value={score} onValueChange={setScore} min={50} max={100}><span>Match threshold</span></Slider>`
  - Do: `<Slider aria-label="Match threshold" value={score} onValueChange={setScore} min={50} max={100}><span>Match threshold</span></Slider>`
- `rule/slider-range-in-the-filter-bar`: When a range filters a list that also has other filters, pass it to `FilterBar` as a filter with `type: "range"` instead of a separate `RangeFilter` beside the bar, because the bar then counts a set range, holds it in the phone's Filters sheet and resets it with Clear, where a range beside the bar is left out of all three. Evidence: principle heuristic: consistency and standards, one row of filters counts and clears as one (`registry/cobalt/ui/filter-bar.tsx:311`, `registry/cobalt/ui/filter-bar.tsx:316`); single use `docs/system/examples/slider/in-filter-bar.tsx:25`. Check: review of every `RangeFilter` placed next to a `FilterBar`.
  - Don't: `<FilterBar filters={[type]} />` beside `<RangeFilter label="Assets" value={assets} onValueChange={setAssets} min={1e6} max={1e12} />`
  - Do: `<FilterBar filters={[{ key: "assets", type: "range", label: "Assets", value: assets, onValueChange: setAssets, min: 1e6, max: 1e12 }, type]} />`

### Content
- Follows `rule/writing-field-label-noun`.
- `rule/slider-label-is-the-measure`: When naming a `RangeField` or a `RangeFilter`, set `label` to the noun for what is measured, such as "Assets" or "Fund age, in years", in sentence case, instead of a question such as "How big?", because the one label names the track, both fields ("Assets, Minimum") and the pill ("Assets $1B or more"). Evidence: principle heuristic: match between system and the real world, `registry/cobalt/ui/range-filter.tsx:26` writes the pill as the label and then the range; app 3/3 labels in docs/system/examples/slider are nouns. Check: review.
  - Don't: `<RangeFilter label="How big is the fund?" value={assets} onValueChange={setAssets} min={1e6} max={1e12} />`
  - Do: `<RangeFilter label="Assets" value={assets} onValueChange={setAssets} min={1e6} max={1e12} />`
- `rule/slider-preset-words-match`: When writing a preset's `label`, write the range in the words the pill uses for it, such as "$1B or more", instead of a name such as "Large funds", because once the preset is on, the pill reads "Assets $1B or more" and a different name for the same range reads as a second filter. Evidence: principle heuristic: consistency and standards, one range has one wording; single use `docs/system/examples/slider/in-filter-bar.tsx:34-36`. Check: review of every `presets` array.
  - Don't: `presets={[{ label: "Large funds", value: [1e9, null] }]}`
  - Do: `presets={[{ label: "$1B or more", value: [1e9, null] }]}`

### Anti-slop
- `rule/slider-no-value-bubble`: When a slider's figure must be read, put `SliderValue` in the line above the track, beside the label, instead of a bubble or a tooltip over the thumb, because a bubble sits under the finger on a phone and moves with every step, while the figure in the line changes in place in tabular figures. Evidence: person D37; principle input: on touch the finger covers the thumb. Check: review of every `Slider` with a floating figure.
  - Don't: `<Slider aria-label="Match threshold" value={score} onValueChange={setScore}><span className="absolute -top-8">{score}%</span></Slider>`
  - Do: `<Slider aria-label="Match threshold" value={score} onValueChange={setScore}><span>Match threshold</span><SliderValue /></Slider>`
- `rule/slider-range-filter-not-two-inputs`: When a list is filtered by a range of numbers, use `RangeFilter` instead of two `Input`s or a bare `Slider` in the filter row, because `RangeFilter` reads "50M" and "1.2B", keeps an empty end as "No minimum", and sends the list only finished ranges. Evidence: principle heuristic: recognition rather than recall, the pill says the range that is on; single use `docs/system/examples/slider/in-filter-bar.tsx:25`. Check: review of every filter row with a numeric bound.
  - Don't: `<Input placeholder="Min assets" /><Input placeholder="Max assets" />`
  - Do: `<RangeFilter label="Assets" value={assets} onValueChange={setAssets} min={1e6} max={1e12} scale="log" kind="money" />`

### Limits
- `rule/slider-filter-label-length`: When a `RangeFilter`'s `label` runs past 22 characters, shorten it, such as "Assets" for "Assets under management", instead of letting the pill cut it, because the pill holds one line and cuts at its end, which is the range, and the whole of it shows only in a tooltip under a pointer, which a touch screen never opens. Evidence: measured at 390 on /components/slider, in the example's 310px row, the pill cuts "Assets under management $1.2B to $50B" at its 37th character, and the stress page cuts "Verwaltetes Vermögen $50T to $200T" at 320. Check: review of every `RangeFilter` `label`.
  - Don't: `<RangeFilter label="Assets under management in US dollars" value={assets} onValueChange={setAssets} min={1e6} max={1e12} />`
  - Do: `<RangeFilter label="Assets" value={assets} onValueChange={setAssets} min={1e6} max={1e12} />`

## Accessibility
Rests on Base UI `Slider`, whose thumbs are native `input type="range"` elements. `RangeField`'s fields are the system `Input` with their own `label` elements, and `RangeFilter` rests on the system `Popover`, a Base UI popover that becomes the system `Sheet` below 640px. Screen reader pass with VoiceOver: NEEDS REVIEW. Right to left: NEEDS REVIEW.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before a `RangeField` | focuses the low thumb, then the high thumb, then the low field, then the high field | the next part (measured in that order) | by hand |
| Right or Up | a thumb | one `step` up; on a log track one stop, about 12 percent | the thumb | by hand |
| Left or Down | a thumb | one step down | the thumb | by hand |
| Shift with an arrow, Page Up, Page Down | a thumb | `largeStep`: a tenth of a linear `RangeField`'s track, a decade on a log track (measured: +4 on the 0 to 40 track) | the thumb | by hand |
| Home, End | a thumb | to the track's start or end, or to the other thumb, which stops it (measured: End on the low thumb stopped at the high thumb's 20) | the thumb | by hand |
| Enter | a field | reads the typed bound: moves its thumb, or keeps the words and says why | stays in the field | by hand |
| Tab, Shift+Tab | a field | reads the typed bound, as Enter does | the next or previous part | by hand |
| Enter, Space | the filter pill | opens the popover; each key step inside is a finished change, so the pill and the list follow each one | the low thumb (measured); below 640px the sheet itself | by hand |
| Escape | inside the filter's popover | closes it | the pill (measured) | by hand |
| Enter | `Clear` in the popover | removes both bounds; with none set, does nothing | stays on `Clear` (measured) | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| thumb | slider, an `input type="range"` | `aria-label`; a range adds ", Minimum" and ", Maximum" from `labels` | `aria-valuenow`, `aria-valuetext` from `getAriaValueText`, `aria-orientation="horizontal"`, `disabled` | the name and the value text as it changes; on a log track the value text says "$1B" while `aria-valuenow` is a stop from 0 to 120 (measured) | test |
| `SliderValue` | status, an `output` | none | `aria-live="off"`, `for` the thumbs | nothing; the thumb speaks the value | by hand |
| `RangeField` | group | `label`, through `aria-label` | none | the name as focus enters | by hand |
| fields | textbox | `aria-label` "Assets, Minimum" from `label`, else the visible label | `aria-invalid` while refused, `aria-describedby` the line, `inputmode="decimal"`, `autocomplete="off"` | the name, the value and the line under the fields | test |
| line under the fields | none, `aria-live="polite"` | none | the wording not shown is `aria-hidden` | the reason once, when a field is left holding one | by hand |
| filter pill | button | its words; once on, `aria-label` with the same words, such as "Assets $1B or more" | `aria-haspopup="dialog"`, `aria-expanded`, `aria-controls` while open | the words, "button" and collapsed or expanded | test |
| filter popover | dialog | `aria-label` from `label`; below 640px the sheet's title, the same words | none | the name as it opens | by hand |
| presets | group of toggle buttons | "Common ranges" from `labels.presets`; each preset its text | `aria-pressed` | the preset and whether it is pressed | by hand |

## Tokens
| Part | State | Token |
|---|---|---|
| control | all | `--control` |
| track | all | `--muted` |
| fill | all | `--primary` |
| thumb | all | `--card`, `--shadow-raised`; `--foreground` in dark mode |
| thumb | focus-visible | `--ring`, `--line-focus`, `--focus-offset` |
| `SliderValue` | all | `--muted-foreground` |
| fields | all | the Input's: `--control`, `--r-control`, `--input`; `--primary` for the edge after Tab |
| fields | refused | `--destructive` |
| line under the fields | all | `--muted-foreground`, `--destructive`, `--t-press`, `--t-pop`, `--t-icon` |
| filter pill | off, hover, on | `--control-sm`, `--r-control`, `--muted`, `--muted-hover`, `--foreground`, `--background` |
| filter pill's tooltip | cut, under the pointer | `--tip`, `--tip-foreground` |
| filter popover | open | `--popover`, `--shadow-floating`, `--pad-card-sm`, `--t-pop`, `--curve` |

The fill takes the accent as a fill that measures, as Progress and Meter do under D46, and the 6px track is fully round like their tracks; `--r-track` belongs to the container track of the segmented control and the tabs. Whether D46 should name the slider is a question for Kaan.

## Related
- NumberField: one exact number, typed or stepped.
- FilterBar: filters over named choices, and the row a `RangeFilter` joins.
- SegmentedControl: one of a few named settings.
- Meter: a value shown against a limit, read and never set.
- DatePicker: a range of dates.
