Skip to content
GitHub (opens in a new tab)

Slider

Pick a value or a range along a track.

stableAtomcontracts/slider.json

Preview

Slider

Pick a value or range along a track. Range is a two-value array, not RangeSlider. Vertical is orientation, not a cousin.

Master

Single value with a live number. Drag the thumb or use arrow keys.

33

Usage

Controlled value with min, max, and step. Each thumb is role=slider with keyboard support. Inside Field, the label names every thumb; on its own, pass aria-label.

Do's

  • Adjust a numeric setting on a continuous scale
  • Pick a min and max range for filters
  • Volume, brightness, or percent controls in a form

Don'ts

<Field label="Volume" htmlFor="volume">
  <Slider id="volume" value={33} min={0} max={100} onValueChange={setValue} />
</Field>

Pick a value or range along a track. One piece. Range is a two-value array, not a RangeSlider cousin.

When to use

  • Adjust a numeric setting on a continuous scale
  • Pick a min and max range for filters
  • Volume, brightness, or percent controls in a form

When not to use

  • Discrete choices from a short list — use RadioGroup or Select
  • On/off settings — use Switch
  • Determinate task completion — use Progress

What an agent reads

import { Slider } from "agentic-ds-kit";
must
  • Each thumb has role=slider and an accessible name: aria-label, aria-labelledby, or the Field label via labelledBy
  • describedBy and error land on each thumb (aria-describedby, aria-invalid)
  • aria-valuemin, aria-valuemax, aria-valuenow on each thumb
  • Arrow keys adjust by step. Home and End jump to min and max
  • Focus ring on thumb focus-visible
defaults
  • min 0
  • max 100
  • step 1
  • orientation horizontal
  • disabled false
stops if
  • Do not invent SliderTrack, SliderThumb, SliderRange, RangeSlider, or VerticalSlider
  • Do not use raw hex
  • Do not use radix or @base-ui/react
  • Do not use a native range input

From contracts/slider.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
labelledBystringNo—Id(s) of the visible label for each thumb's aria-labelledby. Field passes its label id, so a Slider inside Field is named by the Field label.
describedBystringNo—Id(s) for each thumb's aria-describedby. Field passes its hint or error id.
errorbooleanNo—Marks each thumb aria-invalid. Field sets it when it has an error.
valuenumber | number[]Yes—Current value. Single number for one thumb. Two numbers for a range.
minnumberNo0—
maxnumberNo100—
stepnumberNo1—
orientationhorizontal | verticalNohorizontalVertical is orientation, not a VerticalSlider cousin.
disabledbooleanNofalse—
onValueChangefunctionNo—Called with the next value or value array.
  • Component
    →

    RadioGroup

    Choose exactly one option from a small visible set.

  • Component
    →

    Select

    Choose one or several options from a list.

  • Component
    →

    Switch

    Immediate on/off setting.

  • Component
    →

    Progress

    Task completion as a bar or circle from 0 to 100, or an indeterminate bar when the percent is not known.