You need turn off scrolling in the sidenav and turn in on for only the scrollable content which is everything except the toolbar (all your h4s). To do that, add a DIV around the scrollable content below the toolbar, and apply style to fix the height of the toolbar and allow the scrollable section to fill the remaining space inside a flexbox.
<mat-toolbar style="flex: 0 0 128px;">HELLO</mat-toolbar>
<div style="overflow-y: auto;">
<!- menu content -->
</div>
Also add some style to the menu content container to turn off vertical scrolling and provide the flexbox layout for the menu content.
.no-v-scroll {
height: 100%;
overflow-y: hidden;
display: flex;
flex-direction: column;
}
In Angular Material v6 you can apply that style directly to mat-sidenav
:
<mat-sidenav class="no-v-scroll" style="width: 320px;">
<mat-toolbar style="flex: 0 0 128px;">HELLO</mat-toolbar>
<div style="overflow-y: auto;">
<!- menu content -->
</div>
</mat-sidenav>
But in v7 an extra DIV is needed around the menu content (toolbar plus scrollable):
<mat-sidenav style="width: 320px;">
<div class="no-v-scroll">
<mat-toolbar style="flex: 0 0 128px;">HELLO</mat-toolbar>
<div style="overflow-y: auto;">
<!- menu content -->
</div>
</div>
</mat-sidenav>
As mentioned in the OP's answer, you can also override the mat-drawer-inner-container
class if you don't want to add this extra DIV.
Here is the OP's modified code for v6 on StackBlitz.
Here is the OP's modified code for v7 on StackBlitz.