Open In App

How to use <mat-divider> 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-divider> tag is used to separate two sections or content with a horizontal line.

Installation syntax:



ng add @angular/material

Approach:

Project Structure: It will look like the following.



Code Implementation:

app.module.ts: 




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

app.component.html: 




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

Output:


Article Tags :