Providing an image avatar within a mat-card-header
is well supported via mat-card-avatar
.
There are many use-cases where we'd like to use an icon, instead of an image, as the card's "avatar".
Is there an easy way to replace the avatar with an icon?
This below sort of works, but is not quite as nice as the avatar image.
Try adding display: inline-block !
The <mat-card> is a container for the content that can be used to insert the media, text & action in context to the single subject. The basic requirement for design the card is only an <mat-card> element that has some content in it, that will be used to build simple cards.
The mat-card-avatar
directive can be applied to any element including <mat-icon>
. You will need to apply style to the icon to get the size right:
<mat-card>
<mat-card-header>
<mat-icon mat-card-avatar>home</mat-icon>
...
mat-icon.mat-card-avatar {
width: 40px;
height: 40px;
font-size: 40px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With