Having trouble getting help?
Contact Support
Contact Support
Customize limits in Angular Range Slider component
10 Jan 20254 minutes to read
Slider appearance can be customized via CSS. By overriding the slider CSS classes, the slider limit bar can be customized. Here, the limit bar is customized with different background color. By default, the slider has class e-limits
for limits bar. You can override the class with our own color values as given in the following code snippet.
.e-slider-container.e-horizontal .e-limits {
background-color: rgba(69, 100, 233, 0.46);
}
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
import { SliderModule, SliderComponent, LimitDataModel, SliderType, TicksDataModel, TooltipDataModel } from '@syncfusion/ej2-angular-inputs';
@Component({
imports: [
SliderModule
],
standalone: true,
selector: 'my-app',
template: ` <div class='sliderwrap'>
<label class="labeltext">MinRange Slider With Limits</label>
<ejs-slider id='minrange' #minrange [value]='minValue' [min]='min' [max]='max' [tooltip]='tooltip' [ticks]='ticks' [type]='minType'
[limits]='minRangeLimits'></ejs-slider>
</div>
<div class='sliderwrap'>
<label class="labeltext">Range Slider With Limits</label>
<ejs-slider id='range' #range [value]='rangeValue' [min]='min' [max]='max' [tooltip]='tooltip' [ticks]='ticks' [type]='rangetype'
[limits]='rangeLimits'></ejs-slider>
</div>`,
})
export class AppComponent {
@ViewChild('minrange')
public minrangeObj?: SliderComponent;
@ViewChild('range')
public rangeObj?: SliderComponent;
public min: number = 0;
public max: number = 100;
public minValue: number = 30;
public rangeValue: number[] = [30, 70];
public tooltip: TooltipDataModel = {
placement: 'Before',
isVisible: true
};
public ticks: TicksDataModel = {
placement: 'After',
largeStep: 20,
smallStep: 5,
showSmallTicks: true
};
public minType: SliderType = 'MinRange';
public rangetype: SliderType = 'Range';
public minRangeLimits: LimitDataModel = { enabled: true, minStart: 10, minEnd: 40 };
public rangeLimits: LimitDataModel = { enabled: true, minStart: 10, minEnd: 40, maxStart: 60, maxEnd: 90 };
}
@import 'node_modules/@syncfusion/ej2-base/styles/material.css';
@import 'node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import 'node_modules/@syncfusion/ej2-popups/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-inputs/styles/material.css';
.sliderwrap {
margin-top: 45px;
width: 400px;
margin: 0 auto;
}
.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 */
}
#range .e-limits,
#minrange .e-limits {
background-color: #ccc;
background-color: rgba(69, 100, 233, 0.46);
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));