Search code examples
cssangularangular-materialcss-gridmat-sidenav

How can I make mat-sidenav take up entire vertical space underneath mat-toolbar?


I'm trying to get the following angular-material layout working. I have a mat-toolbar at the top, and mat-sidenav on the bottom. No matter what I try, I can't get the mat-sidenav-container to take up the whole page height. This is my attempt using grid layout. It looks like it should work, but it doesn't. It seems like the mat-sidenav automatically shrinks to the height of element inside mat-sidenav-content.

enter image description here

Here's my html:

<div class="main-div">
  <app-header class="app-header"></app-header>
  <app-sidenav class="app-sidenav"></app-sidenav>
</div>

Here's my css:

.main-div {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.app-header {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.app-sidenav {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
}

Solution

  • Try adding this

    .main-div {
       display: grid;
       grid-template-columns: 1fr;
       grid-template-rows: auto 1fr;
       height: 100vh;
    }
    .mat-sidenav-container {
       height: 100%;
    }