noUiSlider: Lightweight JavaScript Range Slider

15.8.1 · active · verified Sun Apr 19

noUiSlider is an unopinionated, lightweight, and accessible JavaScript range slider library designed for modern web applications. It offers GPU-animated performance, ensuring smooth operation even on older devices, and supports all modern browsers including IE > 9. Its key differentiators include having no external dependencies, full responsiveness, multi-touch support for various mobile platforms, and comprehensive accessibility features with ARIA and keyboard navigation. The current stable version is 15.8.1. The project maintains a regular release cadence, often issuing patch and minor releases to address bug fixes, add new features, and refine TypeScript definitions, as seen in its recent release history (e.g., 15.8.1, 15.8.0, 15.7.2).

Common errors

Warnings

Install

Imports

Quickstart

This quickstart code demonstrates how to initialize a basic noUiSlider with two handles, connect the range, add tooltips and pips, and listen for update events. It also shows programmatic value setting.

import * as noUiSlider from 'nouislider';
import 'nouislider/dist/nouislider.css';

const sliderElement = document.createElement('div');
sliderElement.id = 'mySlider';
document.body.appendChild(sliderElement);

const slider = noUiSlider.create(sliderElement, {
  start: [20, 80],
  connect: true,
  range: {
    'min': 0,
    'max': 100
  },
  tooltips: true,
  pips: {
    mode: 'steps',
    stepped: true,
    density: 4
  }
});

slider.on('update', (values, handle) => {
  console.log(`Slider updated: Handle ${handle} value: ${values[handle]}`);
});

// Example of setting new values programmatically
setTimeout(() => {
  slider.set([30, 70]);
  console.log('Slider values set to [30, 70] after 2 seconds.');
}, 2000);

view raw JSON →