mat-slide-toggle 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-slide-toggle is a kind of switch or button that is used to toggle between states like one and off or true or false.
ng add @angular/material
- First, install the angular material using the above-mentioned command.
- After completing the installation, Import ‘MatSlideToggleModule’ from ‘@angular/material/slide-toggle’ in the app.module.ts file.
- Then use the mat-slide-toggle tag to display a toggle button.
- And in order to write the significance of that button then we need to mention it between the opening and closing tags.
- 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.
- Once done with the above steps then serve or start the project.