Slider

A number you drag.

Default

One handle between 0 and 100.

One handle for a value, two for a range. The arrow keys move by one step, Home and End jump to the ends, and the whole track is clickable — the handle goes where you click.

Installation

npx philcn@latest add slider

The file is written into your project. It is yours from then on — change it as you like.

Examples

A range

Two handles that cannot cross, and a value you hold yourself.

20 to 70

Props

PropTypeWhat it does
Slider.valuenumber[]Controlled. Always an array, even with one handle.
Slider.defaultValuenumber[]Uncontrolled: where the handles start.
Slider.onValueChange((value: number[]) => void)Called on every movement, while dragging.
Slider.onValueCommit((value: number[]) => void)Called once, when the handle is let go. Use this one to save or to fetch.
Slider.minnumberThe low end. 0 by default.
Slider.maxnumberThe high end. 100 by default.
Slider.stepnumberHow far one arrow key press moves.
Slider.minStepsBetweenThumbsnumberHow many steps two handles must keep between them, so they cannot cross or overlap.
Slider.orientation"horizontal" | "vertical"Horizontal or vertical.

Types are read from the library itself, so this table cannot describe an option the code no longer has.