Angular 5 Material Snackbar panelClass config
In my case all above doesn't work. It starts working when I add !important
in css
:
.error-snackbar {
background-color: fuchsia !important;
}
In your component SnackBarComponentExample try:
saveButtonClick = () =>{
let config = new MatSnackBarConfig();
config.duration = 5000;
config.panelClass = ['red-snackbar']
this.snackBar.open("This is a message!", "ACTION", config);
}
Where 'red-snackbar'
is a class in your apps main styles.css
file. Strangely I was unable to get the config.panelClass
to work when I was referencing my components associated css file, but once I put the class into the main styles.css
file my styles were applied correctly to the snackBar.