42

Is there any way to remove the border, I think it's the box-shadow of a mat-expansion-panel from Angular Material? I want it to be all white, so you only would see Text and expansion arrow

<mat-accordion>
 <mat-expansion-panel class="" (opened)="panelOpenState = true"
                   (closed)="panelOpenState = false">

   <mat-expansion-panel-header>

     <mat-panel-title>
       <span class="right">Filter</span>
     </mat-panel-title>

   </mat-expansion-panel-header>

   <p><app-data></app-data></p>

 </mat-expansion-panel>
</mat-accordion>

Mat-Panel

Edric
  • 24,639
  • 13
  • 81
  • 91
Sergi
  • 743
  • 1
  • 9
  • 17

6 Answers6

100

add mat-elevation-z0 class. Works like a charm, I needed to use that recently.

<mat-accordion>
 <mat-expansion-panel class="mat-elevation-z0" (opened)="panelOpenState = true"
                   (closed)="panelOpenState = false">

   <mat-expansion-panel-header>

     <mat-panel-title>
       <span class="right">Filter</span>
     </mat-panel-title>

   </mat-expansion-panel-header>

   <p><app-data></app-data></p>

 </mat-expansion-panel>
</mat-accordion>
Tomasz Błachut
  • 2,368
  • 1
  • 16
  • 23
17

I do it with css:

.mat-expansion-panel:not([class*='mat-elevation-z']) {
    box-shadow: none;
}
JBeen
  • 390
  • 4
  • 9
6

Yes, You can remove box-shadow and border: Just Put in CSS or SCSS (Real-time work)

.mat-expansion-panel{
    box-shadow: none !important;
}
Sarfaroj
  • 61
  • 1
  • 4
1
.mat-expansion-panel:not([class*='mat-elevation-z']) {
  box-shadow: 0px 0px 0px -2px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12); 
}

This will do.

Nick
  • 138,499
  • 22
  • 57
  • 95
Jay
  • 135
  • 8
0

To get rid of the default border-radius you might to override the default border-radius values which you can find inspecting mat-expansion-panel in the browser inspector.

enter image description here

As you can see .mat-accordion .mat-expansion-panel:last-of-type and .mat-accordion .mat-expansion-panel:first-of-type sets the 4px border-radius

border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;

border-top-right-radius: 4px; border-top-left-radius: 4px;

The below solution helps to precise override those values:

.mat-accordion {
    & > .mat-expansion-panel {
      &:first-of-type,
      &:last-of-type {
        border-radius: unset;
      }
    }
Mikolaj
  • 1,231
  • 1
  • 16
  • 34
-2

You can as well toggle the class mat-expansion-panel by doing

<mat-accordion>
  <mat-expansion-panel [class.mat-expansion-panel]="false">
     ...
  </mat-expansion-panel>
</mat-accordion>