Skip to content

Slider

Stable

A single-thumb slider for picking a number in a range, with an optional value readout.

Also known as range, range slider, range input

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Basic slider

The value runs from 0 to 100 by default.

When to use it

Lets a person pick a number from a range by dragging or using the arrow keys. It suits settings where a rough value is fine.

Made of: Track · Filled track · Thumb · Value text

Use it for

  • A setting with a clear minimum and maximum, such as creativity or volume.
  • A value that people adjust and compare by feel.
  • A number with steps, such as a length in rounds of 256.

Not for

Do and avoid

$120
Do. A rough limit people can drag, with the value shown.
Avoid. Dragging to an exact amount is fiddly, and the value is hidden.

Do

  • Show the value, so people know what they have picked.
  • Pick a step that matches how precise the setting needs to be.
  • Use formatValue when the number has a unit.
  • Give the slider a width. It fills the space it is given.

Avoid

  • Do not use a Slider when people need to enter an exact number. Use a NumberField.
  • Do not use it for a few named choices. Use a SegmentedControl.
  • Do not use it for a range with two ends. It has one thumb.
  • Do not rely on the filled track alone to show the value.

On a phone

  • The slider is 44px tall on touch screens, so the thumb is easy to grab even though it is drawn 20px wide.
  • It stretches to fill the width of its container, with the value shown beside it when showValue is on.
  • It is the browser's own range input, so a finger drags it directly; for exact numbers, pair it with a NumberField.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started