I cannot make the mat-toolbar
to change color according to my theme. Please see my code:
HTML
<mat-sidenav #drawer class="sidenav" fixedInViewport
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="(isHandset$ | async) === false">
<mat-toolbar color="primary" >Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item href="#">
<mat-icon aria-hidden="false" aria-label="Health Check" color="primary">poll</mat-icon>
Poll
</a>
<a mat-list-item href="#">
<mat-icon aria-hidden="false" aria-label="Health Check" color="primary">info</mat-icon>
Announcements
</a>
</mat-nav-list>
</mat-sidenav>
But in the content, I don't get any issues. Please see my code.
<mat-sidenav-content>
<mat-toolbar color="primary">
<button
type="button"
aria-label="Toggle sidenav"
mat-icon-button
(click)="drawer.toggle()"
*ngIf="isHandset$ | async">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>
<a mat-button href="#">
<mat-icon aria-hidden="false" aria-label="Health Check">accessibility_new</mat-icon>
Health Check
</a>
<span class="spacer"></span>
<div *ngIf="!isXs">
<a mat-button href="#">
<mat-icon aria-hidden="false" aria-label="Health Check">poll</mat-icon>
Poll
</a>
<a mat-button href="#">
<mat-icon aria-hidden="false" aria-label="Health Check">info</mat-icon>
Announcements
</a>
</div>
</mat-toolbar>
<!-- Add Content Here -->
<ng-content></ng-content>
</mat-sidenav-content>
In the mat-nav component need to change css from:
.sidenav .mat-toolbar {
background: inherit;
}
to
.sidenav {
background: inherit;
}
This problem arise when mat-nav component is created by schematics.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.