Angular Material 7 - Expansion Panel

The <mat-expansion-panel>, an Angular Directive, is used to create an expandable detail v/s summary view.

  • <mat-expansion-panel-header> − Represents the header section. Contains summary of panel and acts as control to expand or collapse the panel.

  • <mat-panel-title> − Represents the panel title.

  • <mat-panel-description> − Represents the panel summary.

  • <mat-action-row> − Represents the actions panel at the bottom.

In this chapter, we will showcase the configuration required to draw a expansion control using Angular Material.

Create Angular Application

Follow the following steps to update the Angular application we created in Angular 6 - Project Setup chapter −

Step Description
1 Create a project with a name materialApp as explained in the Angular 6 - Project Setup chapter.
2 Modify app.module.ts, app.component.ts, app.component.css and app.component.html as explained below. Keep rest of the files unchanged.
3 Compile and run the application to verify the result of the implemented logic.

Following is the content of the modified module descriptor app.module.ts.

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

Following is the content of the modified HTML host file app.component.html.

         Personal data
         Type name and age
      <input matInput placeholder="Name">
      <input matInput placeholder="Age">


Verify the result.

Expansion Panel


  • As first, we've created expansion panel using mat-expansion-panel.
  • Then, we've added title, subtitle and content to it.
Kickstart Your Career

Get certified by completing the course

Get Started