I am trying to change the color of the angular material dialog using css var (), but instead of the color I need, the background bees 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'
});
}
I am trying to change the color of the angular material dialog using css var (), but instead of the color I need, the background bees 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'
});
}
Share
Improve this question
asked Apr 4, 2020 at 16:11
Nikita KachanNikita Kachan
731 gold badge1 silver badge3 bronze badges
1
- Does this answer your question? How to close a mat dialog without a backdrop on clicking outside? – Dane Brouwer Commented Mar 17, 2021 at 12:40
2 Answers
Reset to default 5You need to use ::ng-deep
to force the style down to angular material ponents:
::ng-deep .custom-dialog > mat-dialog-container {
background-color: var(--background);
}
See working example: https://stackblitz./angular/ebnbevodyrv
To change anything in angular-material library UI, need to add css in styles.scss i.e. root level.
See here