Clinia UI

Slider

Sets a value in a range by dragging, when position matters more than the exact number.

shadcn docs →

When to use

  • Set a value in a range where the rough position matters more than the exact number: a match threshold, a volume, a zoom level.
  • Pick a range with two thumbs, such as a minimum and maximum age.

When not to use

  • An exact number, or a range wider than a few hundred steps: use Input with type="number".
  • A handful of named levels: use Radio Group or Toggle Group.

Install

npx shadcn@latest add @clinia/slider
60%

Anatomy

  1. 1Trackdata-slot="slider-track"bg-input · h-2
  2. 2Rangedata-slot="slider-range"bg-primary
  3. 3Thumbdata-slot="slider-thumb"ring-input · has-focus-visible:ring-ring

Clinia rules

  • The track is the input token and the filled range is primary, so both clear 3:1. Trust only appears in the thumb's hover and focus halo.
  • Always show the current value as text beside the label. The thumb position alone is not a value.
  • Pass defaultValue or value as an array. With neither, the slider renders two thumbs, at min and max.

Do and don't

60%
Do show the value beside the label.
Don't use a slider for an exact number: use Input.

States

single
range
disabled
vertical
focus

Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.

Accessibility

Built in

  • When the thumb has keyboard focus it shows a solid 2px Trust ring with an offset. Hover adds a wider halo.
  • Each thumb is a native range input. Arrow keys move one step, Shift+Arrow and Page Up or Page Down move largeStep (10 by default), and Home and End jump to the ends.

Your responsibility

  • Name the slider: aria-label on Slider, or a Label whose id the slider references with aria-labelledby. A Label without a target names nothing.
  • For a range, give each thumb its own name, such as Minimum age and Maximum age.
  • If the number needs a unit, pass getAriaValueText so a screen reader hears 60 percent, not just 60.

How to test

  1. Press Tab to reach the thumb: the focus halo appears around it.
  2. Press Arrow Right: the value goes up by one step and the visible value updates. Shift+Arrow Right jumps by ten.
  3. Press Home, then End: the thumb jumps to the minimum, then the maximum.
  4. With a screen reader, it announces the slider's name and its current value.

API

Every prop comes from Base UI Slider.