Skip to content
Related Articles
Open in App
Not now

Related Articles

How to use <mat-divider> in Angular Material ?

Improve Article
Save Article
  • Last Updated : 05 Feb, 2021
Improve Article
Save 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-divider> tag is used to separate two sections or content with a horizontal line.

Installation syntax:

ng add @angular/material


  • First, install the angular material using the above-mentioned command.
  • After completing the installation, Import ‘MatDividerModule’ from ‘@angular/material/divider’ in the app.module.ts file.
  • After importing the ‘MatDividerModule’ we need to use <mat-divider> tag.
  • When we use <mat-divider>, a horizontal grey line is rendered on the screen.
  • The main purpose of this tag is to separate any two-block, div, or any sections.
  • Once done with the above steps then serve or start the project.

Project Structure: It will look like the following.

Code Implementation:



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



<h1 style="color:green">
<mat-divider> </mat-divider>
<h5>One stop Solution for all CS subjects</h5>
<mat-divider> </mat-divider>
    The above horizontal line is displayed 
    due to the presence of mat-divider tag.


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!