<div fxHide fxHide.xs="false" fxHide.md="true">
<button mat-icon-button [matMenuTriggerFor]="menu" class="my-menu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item *ngFor="let menu of repoService.toolbarMenu" class="mr-4" (click)="repoService.onToolbarClick(menu)"
class="notifications-dropdown">
<mat-icon *ngIf="menu.icon" aria-label="menu.key" class="mr-4">{{menu.icon}}</mat-icon>
<span class="notification-row">{{menu.displayKey | translate}}</span>
</button>
</mat-menu>
Css File
.mat-menu-panel.notifications-dropdown {
max-width:none;
width: 100vw;
margin-left: -8px;
margin-top: 24px;
overflow: visible;
}
.notification-row{
width: 424px;
}
I have already tried this, but it doesn't work for me!
md-menu override default max-width in Angular 2
Just wrap the content of the mat-menu and apply the width to the wrapper itself, like in the following example:
To change the width of your menu you can add the following CSS to your menu theme by going to Mega Menu > Menu Themes > Custom CSS.
The default size of a mat icon is 24px. Which basically means that the properties are set to 24px. So, if you want to change the size of a mat-icon, you should always change the value of the font-size, width and height and keep all three values the same to avoid any problem. .
To change the menu position we can use xPosition and yPosition properties of mat-menu selector. If you want display menu before and after the menu trigger element we can pass xPosition value as “before” or “after”.
i had the same issue and solved it by overriding the mat-menu-panel max width property:
::ng-deep.mat-menu-panel {
max-width: none !important;
}
hope it helps
https://material.angular.io/components/menu/api
@Input('class') panelClass: string
This method takes classes set on the host mat-menu element and applies them on the menu template that displays in the overlay container. Otherwise, it's difficult to style the containing menu from outside the component.
<mat-menu class="my-class" ... >
component css (needs ng-deep due to cdk-overlay):
::ng-deep {.mat-menu-panel.my-class { width: 400px; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With