DevExtreme v24.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

JavaScript/jQuery Range Slider

The JavaScript RangeSlider component allows users to choose a range of numeric values. This demo shows how you can create and configure a JavaScript RangeSlider.

DevExtreme Accessibility Compliance
DevExtreme component libraries meet a variety of WCAG and Section 508 compliance standards. To assess this demo’s accessibility level, click the Run AXE® Validation button to launch the AXE® web accessibility evaluation tool.
All trademarks or registered trademarks are property of their respective owners. AXE® Terms of Use
The overall accessibility level of your application depends on the RangeSlider features used.
Backend API
$(() => { $('#range-slider-simple').dxRangeSlider({ min: 0, max: 100, start: 20, end: 60, }); $('#range-slider-with-label').dxRangeSlider({ min: 0, max: 100, start: 35, end: 65, label: { visible: true, format(value) { return `${value}%`; }, position: 'top', }, }); $('#range-slider-with-tooltip').dxRangeSlider({ min: 0, max: 100, start: 15, end: 65, tooltip: { enabled: true, format(value) { return `${value}%`; }, showMode: 'always', position: 'bottom', }, }); $('#range-slider-with-hide-range').dxRangeSlider({ min: 0, max: 100, start: 20, end: 80, showRange: false, }); $('#range-slider-with-step').dxRangeSlider({ min: 0, max: 100, start: 20, end: 70, step: 10, tooltip: { enabled: true, }, }); $('#range-slider-disabled').dxRangeSlider({ min: 0, max: 100, start: 25, end: 75, disabled: true, }); const onHandleMoveRangeSlider = $('#slider-on-handle-move').dxRangeSlider({ min: 0, max: 100, start: 10, end: 90, onValueChanged({ value, start, end }) { onHandleReleaseRangeSlider.option('value', value); startValue.option('value', start); endValue.option('value', end); }, }).dxRangeSlider('instance'); const onHandleReleaseRangeSlider = $('#slider-on-handle-release').dxRangeSlider({ min: 0, max: 100, start: 10, end: 90, valueChangeMode: 'onHandleRelease', onValueChanged({ value, start, end }) { onHandleMoveRangeSlider.option('value', value); startValue.option('value', start); endValue.option('value', end); }, }).dxRangeSlider('instance'); const startValue = $('#start-value').dxNumberBox({ value: 10, min: 0, max: 100, showSpinButtons: true, inputAttr: { 'aria-label': 'Start Value' }, onValueChanged({ value }) { onHandleMoveRangeSlider.option('start', value); onHandleReleaseRangeSlider.option('start', value); }, }).dxNumberBox('instance'); const endValue = $('#end-value').dxNumberBox({ value: 90, min: 0, max: 100, showSpinButtons: true, inputAttr: { 'aria-label': 'End Value' }, onValueChanged({ value }) { onHandleMoveRangeSlider.option('end', value); onHandleReleaseRangeSlider.option('end', value); }, }).dxNumberBox('instance'); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/24.1.7/css/dx.light.css" /> <script src="js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div class="form"> <div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">Default mode</div> <div class="dx-field-value"> <div id="range-slider-simple"></div> </div> </div> <div class="dx-field custom-height-slider"> <div class="dx-field-label">With labels</div> <div class="dx-field-value"> <div id="range-slider-with-label"></div> </div> </div> <div class="dx-field custom-height-slider"> <div class="dx-field-label">With tooltips</div> <div class="dx-field-value"> <div id="range-slider-with-tooltip"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Without range highlighting</div> <div class="dx-field-value"> <div id="range-slider-with-hide-range"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">With discrete step</div> <div class="dx-field-value"> <div id="range-slider-with-step"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Disabled</div> <div class="dx-field-value"> <div id="range-slider-disabled"></div> </div> </div> </div> <div class="dx-fieldset"> <div class="dx-fieldset-header">Process Value Changes</div> <div class="dx-field"> <div class="dx-field-label">On handle movement</div> <div class="dx-field-value"> <div id="slider-on-handle-move"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">On handle release</div> <div class="dx-field-value"> <div id="slider-on-handle-release"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Start value</div> <div class="dx-field-value"> <div id="start-value"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">End value</div> <div class="dx-field-value"> <div id="end-value"></div> </div> </div> </div> </div> </div> </body> </html>
.custom-height-slider { height: 75px; } .dx-field > .dx-rangeslider { flex: 1; }

Create a JavaScript RangeSlider

To create a JavaScript RangeSlider, declare it in markup and specify the following four properties:

  • start and end
    Specify the selected interval.

  • min and max
    Limit the range of accepted values.

You can see the resulting JavaScript RangeSlider in the Default mode section of this demo.

Customize JavaScript RangeSlider Appearance

The JavaScript RangeSlider can display labels for the min and max values. To configure the labels, use the label object. In this object, set the visible property to true to display the labels. You can also specify the position and format properties.

The JavaScript RangeSlider can also display a tooltip for slider handles. To display tooltips, you need to configure the tooltip object:

  • Set the enabled property to true to display tooltips.

  • Specify the tooltip position.

  • Specify the format property.

  • Assign 'onHover' or 'always' to the showMode property to change how the component shows tooltips.

Use the showRange property to specify if the selected range should be highlighted. You can also use the step property to specify the value change step for the JavaScript RangeSlider.

If you want to disable the JavaScript RangeSlider, set the disabled property to true.

Handle the Value Change Event

Specify the onValueChanged function to handle the value change. In this demo, the NumberBox components and the JavaScript RangeSlider use this property to exchange values.

The valueChangeMode property allows you to choose when to change the JavaScript RangeSlider value and supports the onHandleMove and onHandleRelease modes. You can see the property's effect in the Process Value Changes section. The first JavaScript RangeSlider changes its value every time a user slides the handle. The second JavaScript RangeSlider changes its value only when the handle is released. These JavaScript RangeSlider values are synchronized.