Components: snack bar: change background color

Created on 8 Feb 2017  路  3Comments  路  Source: angular/components

I use snack-bar to show notifications. I want to change background color when the response is: error (background: red) or success(background : green).

Code:
let config = new MdSnackBarConfig();
config.duration = 500;
snackBarRef = this.snackBar.open("Message", "", config);

snackBarRef.afterOpened().subscribe(()=>{ });
snackBarRef.afterDismissed().subscribe(()=>{ });

I tried to use:
let snackContainer = document.getElementById("cdk-overlay-0");
snackContainer.firstElementChild.setAttribute("style","background-color:red");
but the snack-bar disappear.

Most helpful comment

This was added with https://github.com/angular/material2/pull/2804 which will be in the next release.

All 3 comments

+1, I tried lots of css selectors and couldnt get any luck which sucked a bit.

This was added with https://github.com/angular/material2/pull/2804 which will be in the next release.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MurhafSousli picture MurhafSousli  路  3Comments

LoganDupont picture LoganDupont  路  3Comments

RoxKilly picture RoxKilly  路  3Comments

3mp3ri0r picture 3mp3ri0r  路  3Comments

alanpurple picture alanpurple  路  3Comments