Apply css style to mat-snackbar in angular

Discussão em 'Angular' iniciado por user21234192, Janeiro 14, 2025.

  1. user21234192

    user21234192 Guest

    I'm wondering why I've been stuck with this all afternoon, and I find it embarrassing that something so trivial is so hard to do in angular material.

    I'm trying to apply a custom style to a snackbar once a button is clicked, this is my code :

    this.errormessagecard.open(error.error.message,'Esci', {panelClass : 'error-snackbar'});


    I've literally tried everything:

    In my component.css

    .error-snackbar{
    background-color: red!important;
    }


    error-snackbar{
    background-color: red!important;
    }


    ::ng-deep .error-snackbar{
    background-color: red!important;


    And the same thing in my styles.css

    What I get is always the same result, which is this:

    Snackbar result

    Nothing change, why??

    Continue reading...

Compartilhe esta Página