Skip to content

Commit eb84d5e

Browse files
crisbetojelbourn
authored andcommitted
docs(menu): add live example of menu position (#15591)
Sets up a live example for the menu position inputs.
1 parent 4cccce1 commit eb84d5e

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

src/lib/menu/menu.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ The position can be changed using the `xPosition` (`before | after`) and `yPosit
6868
</button>
6969
```
7070

71+
<!-- example(menu-position) -->
72+
7173
### Nested menu
7274

7375
Material supports the ability for an `mat-menu-item` to open a sub-menu. To do so, you have to define
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** No CSS for this example */
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<button mat-button [matMenuTriggerFor]="aboveMenu">Above</button>
2+
<mat-menu #aboveMenu="matMenu" yPosition="above">
3+
<button mat-menu-item>Item 1</button>
4+
<button mat-menu-item>Item 2</button>
5+
</mat-menu>
6+
7+
<button mat-button [matMenuTriggerFor]="belowMenu">Below</button>
8+
<mat-menu #belowMenu="matMenu" yPosition="below">
9+
<button mat-menu-item>Item 1</button>
10+
<button mat-menu-item>Item 2</button>
11+
</mat-menu>
12+
13+
<button mat-button [matMenuTriggerFor]="beforeMenu">Before</button>
14+
<mat-menu #beforeMenu="matMenu" xPosition="before">
15+
<button mat-menu-item>Item 1</button>
16+
<button mat-menu-item>Item 2</button>
17+
</mat-menu>
18+
19+
20+
<button mat-button [matMenuTriggerFor]="afterMenu">After</button>
21+
<mat-menu #afterMenu="matMenu" xPosition="after">
22+
<button mat-menu-item>Item 1</button>
23+
<button mat-menu-item>Item 2</button>
24+
</mat-menu>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component} from '@angular/core';
2+
3+
/**
4+
* @title Menu positioning
5+
*/
6+
@Component({
7+
selector: 'menu-position-example',
8+
templateUrl: 'menu-position-example.html',
9+
styleUrls: ['menu-position-example.css'],
10+
})
11+
export class MenuPositionExample {}

0 commit comments

Comments
 (0)