- Have a
mat-sidenav
(opened="true"
) withmat-nav-list
- Each
mat-list-item
has amat-icon
and aspan
mat-sidenav-container
hasautosize
directive
But there is no animation during resizing (collapse/expand) of mat-sidenav
.
HTML
<mat-sidenav-container class="example-container" autosize>
<mat-sidenav mode="side" [opened]="true" #sidenav>
<mat-nav-list>
<mat-list-item (click)="isExpanded=!isExpanded">
<mat-icon matListIcon>reorder</mat-icon>
</mat-list-item>
<mat-list-item>
<mat-icon matListIcon>home</mat-icon>
<span *ngIf="isExpanded">Home</span>
</mat-list-item>
<mat-list-item>
<mat-icon matListIcon>person</mat-icon>
<span *ngIf="isExpanded">Athlets</span>
</mat-list-item>
<mat-list-item>
<mat-icon matListIcon>group</mat-icon>
<span *ngIf="isExpanded">Teams & Partnerships</span>
</mat-list-item>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<h3>Dashboard</h3>
</mat-sidenav-content>
</mat-sidenav-container>
CSS
.example-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.mat-sidenav {
background-color:#3a3636;
}
.mat-list-item {
color: #faf6f6;
}
.mat-list-item:hover {
color: #3a3636;
background-color:#faf6f6;
}
TS
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
isExpanded = true;
}
If there is no inbuilt implementation for this in Angular Material2, how can I achieve the animation?