Skip to main content

angular material - Accordion expanded panels header background color

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styles: [`
    .mat-expansion-panel.mat-expanded
    .mat-expansion-panel-header{
      background: Thistle;
    }
  `]
})


export class AppComponent { }
app.component.html

<h2 style="padding-top:25px; padding-bottom:25px;">
  Angular Material - How to change
    Accordion expanded panels header background color
</h2>


<mat-accordion multi displayMode="flat">
    
  <mat-expansion-panel hideToggle>
      <mat-expansion-panel-header>
        <mat-panel-title>Assembly</mat-panel-title>
      </mat-expansion-panel-header>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit.
      Integer vitae semper massa. Donec maximus, dui nec
      dignissim blandit, ante odio varius ex,
      nec volutpat erat justo ac magna.
  </mat-expansion-panel>

  <mat-expansion-panel>
    <mat-expansion-panel-header>
      <mat-panel-title>Bash/Shell</mat-panel-title>
    </mat-expansion-panel-header>
    Vivamus ornare ipsum sit amet imperdiet laoreet.
    Cras maximus elementum varius. Integer nisi tellus,
    dapibus vitae neque non, tempor vehicula velit.
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  </mat-expansion-panel>

  <mat-expansion-panel>
    <mat-expansion-panel-header>
      <mat-panel-title>Swift</mat-panel-title>
    </mat-expansion-panel-header>
    Sed vitae felis id velit luctus elementum ut quis nisl. Curabitur
    consectetur, ipsum eget vulputate mattis, odio dolor hendrerit
    massa, eget scelerisque justo tellus eu lectus.
  </mat-expansion-panel>

</mat-accordion>
app.module.ts [import]

import {MatExpansionModule} from '@angular/material/expansion'
More Angular tutorials