Open In App

<mat-expansion-panel> in Angular Material

Introduction:
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-expansion-panel> tag is a kind of dropdown which has collapse and expand functionalities.

Installation syntax:



ng add @angular/material

Approach:

Tag Name Property
<mat-panel-title> It is used to display the title for the panel
<mat-panel-description> It is used to display the information regarding the panel.

Code Implementation:






import { CommonModule } from '@angular/common'
import { NgModule } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { MatExpansionModule } from '@angular/material'
    
import { AppComponent } from './example.component'
    
@NgModule({ 
  declarations: [AppComponent], 
  exports: [AppComponent], 
  imports: [ 
    CommonModule, 
    FormsModule, 
    MatExpansionModule
  
  ], 
}) 
export class AppModule {}




<mat-accordion>
  <mat-expansion-panel >
    <mat-expansion-panel-header>
      <mat-panel-title>
         GEEKSFORGEEKS      
      </mat-panel-title>
      <mat-panel-description>
        Click here to expand the panel      
      </mat-panel-description>
    </mat-expansion-panel-header>
      
<p>One stop portal to all Computer Science Subjects. </p>
  
  </mat-expansion-panel>
  
</mat-accordion>

Output:


Article Tags :