Angular 5 and material - How to change the background color from SnackBar component

Discussão em 'Angular' iniciado por andre luis borges de, Fevereiro 16, 2025.

  1. I have to change the background from the snackbar component. I'm using it to alert or inform the user about some either error or completed action the user did.

    The material version from the project. "@angular/material": "^5.0.0-rc.1",

    The documentation https://material.angular.io/components/snack-bar/api say about an api to change the class.

    panelClass: string | string[] Extra CSS classes to be added to the snack bar container.

    This is what I add in the css file.

    .mycsssnackbartest {
    background-color: blue;
    }


    This is the code to open the snackbar

    this.snackBar.open('Informing the user about sth', 'User Message' , {
    panelClass: ['mycsssnackbartest ']
    } );


    What am I doing wrong?

    Continue reading...

Compartilhe esta Página