Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of Angular material expansion header on hover

I have an Angular Material 7 Expansion Panel. When I hover over one of the mat-expansion-panel-header the color is changing. How can I change this color?

Code:

<mat-accordion>
    <mat-expansion-panel>
          <mat-expansion-panel-header>
            <mat-panel-title>
              Titel
            </mat-panel-title>
            <mat-panel-description>Hi</mat-panel-description>
          </mat-expansion-panel-header>
          Content
    </mat-expansion-panel>
</mat-accordion>
like image 262
A.Service Avatar asked Feb 04 '19 10:02

A.Service


2 Answers

You can add a class to the header and set background color to currentColor on hover something like

<mat-accordion>
    <mat-expansion-panel>
          <mat-expansion-panel-header class="disable_ripple">
            <mat-panel-title>
              Titel
            </mat-panel-title>
            <mat-panel-description>Hi</mat-panel-description>
          </mat-expansion-panel-header>
          Content
    </mat-expansion-panel>
</mat-accordion>

then in css

.disable_ripple:hover{
background: currentColor !important;
}

Working example

like image 74
jitender Avatar answered Nov 24 '22 03:11

jitender


Add this to your component CSS file

mat-expansion-panel-header:hover {
    background-color: currentColor
}
like image 26
Dusan Radovanovic Avatar answered Nov 24 '22 03:11

Dusan Radovanovic