Having trouble getting help?
Contact Support
Contact Support
Customize the limits in EJ2 JavaScript Range Slider control
23 Jan 20259 minutes to read
The appearance of the Range Slider control can be customized via CSS. By overriding the slider CSS classes, you can customize the slider limit bar. The limit bar can be customized with a different background color. By default, the slider has a class named e-limits
for the limits bar, which can be overridden with your own color values as shown in the following code snippet:
.e-slider-container.e-horizontal .e-limits {
background-color: rgba(69, 100, 233, 0.46);
}
import { Slider } from '@syncfusion/ej2-inputs';
// Initialize Range Slider Control
let minRangeObj: Slider = new Slider({
// Set slider minimum and maximum values
min: 0, max: 100,
// Set the value for slider
value: 30,
// Set the step value
step: 1,
// Initialize ticks with placement, largeStep, smallStep
ticks: { placement: 'Before', largeStep: 20, smallStep: 5, showSmallTicks: true },
// Set the type for slider
type: 'MinRange',
// Set the limit values for the slider
limits: { enabled: true, minStart: 10, minEnd: 40 },
// Initialize tooltip with placement and showOn
tooltip: { isVisible: true, placement: 'Before', showOn: 'Focus' }
});
minRangeObj.appendTo('#minrange');
// Initialize Range Slider Control
let rangeObj: Slider = new Slider({
// Set slider minimum and maximum values
min: 0, max: 100,
// Set the initial range values for slider
value: [30, 70],
// Set the step value
step: 1,
// Set the type to render range slider
type: 'Range',
// Initialize ticks with placement, largeStep, smallStep
ticks: { placement: 'Before', largeStep: 20, smallStep: 5, showSmallTicks: true },
// Set the limit values for the slider
limits: { enabled: true, minStart: 10, minEnd: 40, maxStart: 60, maxEnd: 90 },
// Initialize tooltip with placement and showOn
tooltip: { isVisible: true, placement: 'Before', showOn: 'Focus' }
});
rangeObj.appendTo('#range');
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 Range Slider</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential JS 2 Range Slider Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/30.1.37/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/30.1.37/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/30.1.37/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/30.1.37/ej2-buttons/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/30.1.37/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div class="col-lg-8 control-section">
<div class="content-wrapper">
<div class="sliderwrap">
<label class="userselect">MinRange Slider With Limits</label>
<div id="minrange"></div>
</div>
<div class="sliderwrap">
<label class="userselect">Range Slider With Limits</label>
<div id="range"></div>
</div>
</div>
</div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
<style>
.content-wrapper {
width: 52%;
margin: 0 auto;
min-width: 185px;
}
.sliderwrap {
margin-top: 45px;
}
.e-bigger .content-wrapper {
width: 80%;
}
.sliderwrap label {
padding-bottom: 50px;
font-size: 13px;
font-weight: 500;
margin-top: 15px;
display: block;
}
.userselect {
-webkit-user-select: none;
/* Safari 3.1+ */
-moz-user-select: none;
/* Firefox 2+ */
-ms-user-select: none;
/* IE 10+ */
user-select: none;
/* Standard syntax */
}
.property-custom td {
padding: 5px;
}
#range .e-limits,
#minrange .e-limits {
background-color: #ccc;
background-color: rgba(69, 100, 233, 0.46);
}
</style>
</body>
</html>
#container {
visibility: hidden;
}
#loader {
color: #008cff;
font-family: 'Helvetica Neue','calibiri';
font-size: 14px;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}