Open In App

<mat-slider> in Angular Material

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

Approach:

            Property Name                         Significance
            invert In order to display the slider in an inverted direction.
            vertical In order to display the slider in a vertical direction.
            disabled In order to disable the slider

Code Implementation:



app.module.ts:




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'
  
@NgModule({ 
  imports: 
  [ BrowserModule, 
    FormsModule, 
    MatSliderModule], 
  declarations: [ AppComponent ], 
  bootstrap: [ AppComponent ] 
}) 
export class AppModule { }

app.component.html:




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

Output:


Article Tags :