Here we will use the wireframe planning and layout to identify the components and attributes needed.
-
Add the
<mat-toolbar>
,<mat-sidenav-container>
,<mat-sidenav>
containersNote: The
<mat-sidenav>
is the container for the Users master list view, and for now a simple<div>
is the container for the User detail view. -
Add the fxLayout and fxFlex attributes to configure the container layouts and sizing aspects
-
Use
mode="side"
andopened
to lock the sidenav open on the left
<div fxLayout="column" fxFlex>
<mat-toolbar color="primary">
<mat-toolbar-row>
<span>Angular Material</span>
</mat-toolbar-row>
</mat-toolbar>
<mat-sidenav-container fxFlex>
<mat-sidenav mode="side" opened>
Sidenav
</mat-sidenav>
<div class="content">
Page Content
</div>
</mat-sidenav-container>
</div>
Giving the host element a flex property of 1
to fill height and sidenav a default width of 320px
:host {
display: flex;
flex: 1;
}
mat-sidenav {
width: 320px;
}