noUiSlider Range and Handles Reading & Setting Values Formatting Options Tapping, Dragging & Fixed Ranges Examples Events Scale/Pips Updating, Disabling & Styling Download

Getting and setting slider values


Reading slider values

noUiSlider has an API with two simple methods: .get() and .set(). To get the current slider value:


For one-handle sliders, calling .get() will return the value as a 'string'. For multi-handle sliders, an array['string', 'string', ...] will be returned.


Setting slider values

If a slider is configured to use one handle, its current value can be changed using the .set() method.

For sliders with multiple handles, pass an array. One-handled sliders will also accept arrays.

Within an array, any position can be set to null to leave a handle unchanged.

noUiSlider will always limit values to the slider range.

To set a single slider handle, the setHandle method can be used. This method accepts a zero-indexed handle number, a value and optionally a 'fire set event' boolean.

Passing null as the value to setHandle will leave the handle unchanged.

Both the set and setHandle methods have an exactInput argument, which can be used to ignore the stepping configured for the slider.

To return to the initial slider values, the .reset() method can be used. This will only reset the slider values.

var slider = document.getElementById('slider');

noUiSlider.create(slider, /* { options } */);

// Set one handled slider

// Set the upper handle on a slider with two handles,
// don't change the lower one
slider.noUiSlider.set([null, 14]);

// On a slider with three handles,
// set the third to 12 (the handleNumber is 0-indexed),
// fire the set event (default true),
// Don't ignore stepping on the slider (default false)
slider.noUiSlider.setHandle(2, 12, true, true);

// Set both slider handles on a slider with two handles
slider.noUiSlider.set([13.2, 15.7]);

// Set both slider handles on a slider with two handles,
// fire the set event (default true)
// Ignore stepping on the slider (default false)
slider.noUiSlider.set([13.2, 15.7], true, true);

// Return to the 'start' values
// Does NOT reset any other slider properties


Clicking the button below sets the slider, which uses a range from 0 to 100, to 20.

var slider = document.getElementById('slider');

noUiSlider.create(slider, {
    start: [80],
    range: {
        'min': [0],
        'max': [100]
Handling button presses
// Set the slider value to 20
document.getElementById('write-button').addEventListener('click', function () {

// Read the slider value.
document.getElementById('read-button').addEventListener('click', function () {

Number formatting