Your search did not match any results.
Slider

Slider

This demo shows how you can create and configure a Slider.

Create a Slider

To create a Slider, declare it in markup and use the min and max properties to limit the range of accepted values.

You can also specify the value property to change the initial value.

The Default mode section shows a Slider with such a basic setup.

Customize Slider Appearance

Max and min labels

The Slider can display labels for the min and max values. To configure the labels, use the label object. In this object, specify the visible, position, and format properties.

Tooltip

To display a handle tooltip, you need to configure the tooltip object:

  • Set the enabled property to true to display a tooltip.

  • Specify the tooltip position: over or under the Slider.

  • Specify the format property.

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

Range highlight

Use the showRange property to specify if the component should highlight the range between min and value.

Discrete step

Use the step property to specify the value change step for the Slider.

Disabled state

If you want to disable the Slider, 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 component and the Sliders use this function to exchange values.

The valueChangeMode property allows you to choose when the Slider changes its value. Available modes include onHandleMove and onHandleRelease. You can see the property's effect in the Process Value Changes section. The first Slider changes its value while a user slides the handle. The second Slider changes its value only after the user releases the handle. These Slider values are synchronized.

Backend API
Copy to CodePen
Apply
Reset
const DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', ($scope) => { $scope.value = 10; $scope.numberBoxOptions = { min: 0, max: 100, showSpinButtons: true, bindingOptions: { value: 'value', }, }; $scope.slider = { simple: { min: 0, max: 100, value: 90, }, withLabel: { min: 0, max: 100, value: 50, label: { visible: true, format(value) { return `${value}%`; }, position: 'top', }, }, withTooltip: { min: 0, max: 100, value: 35, rtlEnabled: false, tooltip: { enabled: true, format(value) { return `${value}%`; }, showMode: 'always', position: 'bottom', }, }, withHideRange: { min: 0, max: 100, value: 20, showRange: false, }, withStep: { min: 0, max: 100, value: 10, step: 10, tooltip: { enabled: true, }, }, disabled: { min: 0, max: 100, value: 50, disabled: true, }, onHandleMoveOptions: { min: 0, max: 100, bindingOptions: { value: 'value', }, }, onHandleReleaseOptions: { min: 0, max: 100, valueChangeMode: 'onHandleRelease', bindingOptions: { value: 'value', }, }, }; });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <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=1.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/22.2.3/css/dx.light.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/22.2.3/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" ng-app="DemoApp" ng-controller="DemoController"> <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 dx-slider="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 dx-slider="slider.withLabel"></div> </div> </div> <div class="dx-field custom-height-slider"> <div class="dx-field-label">With tooltip</div> <div class="dx-field-value"> <div dx-slider="slider.withTooltip"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Without range highlighting</div> <div class="dx-field-value"> <div dx-slider="slider.withHideRange"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">With discrete step</div> <div class="dx-field-value"> <div dx-slider="slider.withStep"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Disabled</div> <div class="dx-field-value"> <div dx-slider="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 dx-slider="slider.onHandleMoveOptions"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">On handle release</div> <div class="dx-field-value"> <div dx-slider="slider.onHandleReleaseOptions"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Slider value</div> <div class="dx-field-value"> <div dx-number-box="numberBoxOptions"></div> </div> </div> </div> </div> </div> </body> </html>
.custom-height-slider { height: 75px; } .dx-field .dx-slider { flex: 1; }