Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent background in angular material dialog

I am trying to change the color of the angular material dialog using css var (), but instead of the color I need, the background becomes transparent.

Css style:

.custom-dialog >  mat-dialog-container {
  background: var(--background);
}

Open dialog function:

openDialogForCreateDirectory(): void {
    this.dialog.open(CreateDirectoryComponent, {
      width: '400px',
      panelClass: 'custom-dialog'
    });
  }
like image 615
Nikita Kachan Avatar asked Aug 09 '26 17:08

Nikita Kachan


1 Answers

You need to use ::ng-deep to force the style down to angular material components:

::ng-deep .custom-dialog > mat-dialog-container {
  background-color: var(--background);
}

See working example: https://stackblitz.com/angular/ebnbevodyrv

like image 145
Alisson Reinaldo Silva Avatar answered Aug 12 '26 06:08

Alisson Reinaldo Silva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!