Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center text in angular snackbar

what would be the correct way to center text in an angular snackbar?

I've tried this, which doesn't work:

let config = new MatSnackBarConfig();
config.panelClass = 'center';
this.snackBar.open(message, undefined, config);

and then in some css file (either the same component, or in the global file):

.center {
   justify-content: center;
}
like image 252
sarahwc5 Avatar asked Jun 19 '18 21:06

sarahwc5


2 Answers

You can do it with open() and panelClass but you need to modify your CSS:

.center > .mat-simple-snackbar {
  justify-content: center;
}
like image 50
G. Tranter Avatar answered Sep 28 '22 11:09

G. Tranter


Material Guide aside, this works for our software product:

.mat-snack-bar-container {
    text-align: center;
}

.mat-simple-snackbar {
    display: inline-block !important;
}
like image 37
Eduardo Goncalves Avatar answered Sep 28 '22 11:09

Eduardo Goncalves