Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material menu position

Angular material menu (https://material.angular.io/components/menu/overview) overlaps the main menu when sub menu opens. Is there any way i can start the submenu from bottom of my menu button?

I have tried setting css in global css however it gets applied to respective sub menus as well.

.cdk-overlay-pane {margin-top: 40px;} This doesn't work.

Please let me know if anyone has solution.

Thanks.

like image 368
Omkar Puranik Avatar asked Jun 10 '26 09:06

Omkar Puranik


1 Answers

If you add [overlapTrigger]="false" to your mat-menu, you will get desired effect.

With that set, clicking on menu button, dropdown will open under button.

Here is example:

  <button mat-button [matMenuTriggerFor]="menu">Menu</button>
    <mat-menu #menu="matMenu" [overlapTrigger]="false">
       <button mat-menu-item>Item 1</button>
       <button mat-menu-item>Item 2</button>
    </mat-menu>
like image 104
Nenad Radak Avatar answered Jun 12 '26 03:06

Nenad Radak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!