Issue
I am trying to position the MatSnackbar
module to appear at the top of my page.
I have tried using the config
to add customclass
. Here is my code:
component.ts
let config = new MatSnackBarConfig();
config.duration = 50000;
config.panelClass = ['red-snackbar']
this.snackBar.open("Please fill all the details before proceeding.", null, config);
.css
.red-snackbar{
position: absolute !important;
top: 54px;
}
But it is not working. Is it possible to re-position the MatSnackbar?
Solution
You can determine the verticalPosition: MatSnackBarVerticalPosition
as specified by the docs
ts:
openSnackBar(message: string, action: string) {
this.snackBar.open(message, action, {
duration: 2000,
// here specify the position
verticalPosition: 'top'
});
}
Answered By - kboul
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.