Change arrow style for default expansion panel arrow
Yes it is possible. Give your expansion panel a reference id e.g. example
and set the hideToggle
property as true
.
In the <md-panel-description>
, you can place your icons and use the expanded
property of the panel to show or hide the relevant icons.
<md-expansion-panel class="custom-header" hideToggle="true" #example>
<md-expansion-panel-header>
<md-panel-title>
Personal data
</md-panel-title>
<md-panel-description>
Type your name and age
<md-icon *ngIf="!example.expanded">play_arrow</md-icon>
<md-icon *ngIf="example.expanded">arrow_drop_down</md-icon>
</md-panel-description>
</md-expansion-panel-header>
<md-form-field>
<input mdInput placeholder="First name">
</md-form-field>
<md-form-field>
<input mdInput placeholder="Age">
</md-form-field>
</md-expansion-panel>
To provide space between the icon and panel description, add the following classes in your component.css:
.custom-header .mat-expansion-panel-header-title,
.custom-header .mat-expansion-panel-header-description {
flex-basis: 0;
}
.custom-header .mat-expansion-panel-header-description {
justify-content: space-between;
align-items: center;
}
I have used material icons. You can place your custom icons if you want. Here is a link to stackblitz demo.
extended the answer from @Faisal and as per the latest version of angular material, we will use mat
prefix instead of md
for the Material components.
Angular Material 8.1.4
<mat-expansion-panel class="mb-15px" hideToggle="true" #xyz>
<mat-expansion-panel-header>
<mat-panel-title class="font-weight-bold font-small">
Info
</mat-panel-title>
<mat-panel-description>
<mat-icon *ngIf="!xyz.expanded">play_arrow</mat-icon>
<mat-icon *ngIf="xyz.expanded">arrow_drop_down</mat-icon>
</mat-panel-description>
</mat-expansion-panel-header>
<mat-expansion-panel class="mb-15px" hideToggle="true" #xyz>
Stackblitz Demo