Open In App
Related Articles

<mat-slider> in Angular Material

Improve Article
Save Article
Like Article

Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. <mat-slider> tag is used whenever there is a need for a slider in our projects.

Installation syntax:

ng add @angular/material


  • First, install the angular material using the above-mentioned command.
  • After completing the installation, Import ‘MatSliderModule’ from ‘@angular/material/slider’ in the app.module.ts file.
  • Then use the mat-slider tag to display the slider.
  • They are many properties in <mat-slider> which helps us in using it in different scenarios.
  • Some important properties are explained in below table.
  • If we want to change the theme then we can change it by using the color property. In angular we have 3 themes, they are primary, accent, and warn.
  • By default, the accent theme is set.
  • Once done with the above steps then serve or start the project.
            Property Name                        Significance
            invertIn order to display the slider in an inverted direction.
            verticalIn order to display the slider in a vertical direction.
            disabledIn order to disable the slider

Code Implementation:



import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { AppComponent } from './app.component'
import { MatSliderModule } from '@angular/material/slider'
  [ BrowserModule, 
  declarations: [ AppComponent ], 
  bootstrap: [ AppComponent ] 
export class AppModule { }



<p>Default Accent Theme Slider</p>
<p>Primary Theme Slider</p>
<mat-slider color="primary"></mat-slider>
<p>Warn Theme Slider</p>
<mat-slider color="warn"></mat-slider>
<p>Inverted Slider</p>
<mat-slider invert="true"></mat-slider>
<p>Vertical Slider</p>
<mat-slider vertical="true"></mat-slider>
<p>Disabled Slider</p>
<mat-slider disabled="true"></mat-slider>


Last Updated : 01 Feb, 2021
Like Article
Save Article
Similar Reads
Related Tutorials