Skip to main content

angular material - How to use custom label in Tabs

app.component.html

<h2 style="padding-top:25px; padding-bottom:25px;">
    Angular Material - How to use custom label in Tab
</h2>


<mat-tab-group>

    <mat-tab>
        <ng-template mat-tab-label>
            <mat-icon style="margin-right:8px;" >
                favorite
            </mat-icon>
            Favorites
        </ng-template>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Nam tincidunt elit non molestie rutrum.
        Donec blandit risus et sem iaculis aliquam.
    </mat-tab>

    <mat-tab>
        <ng-template mat-tab-label>
            <mat-icon style="margin-right:8px;" >
                star
            </mat-icon>
            Ratings
        </ng-template>
        Cras feugiat pharetra dolor, ac euismod tellus maximus eu.
        Etiam dignissim enim vel lacus molestie, in iaculis tellus
        ultrices.
    </mat-tab>

    <mat-tab>
        <ng-template mat-tab-label>
            <mat-icon style="margin-right:8px;" >
                shopping_cart
            </mat-icon>
            Shopping Cart
        </ng-template>
        Integer rhoncus tristique felis ut dignissim.
    </mat-tab>

</mat-tab-group>
app.module.ts [import]

import { MatTabsModule } from '@angular/material/tabs'
import { MatIconModule } from '@angular/material/icon';
More Angular tutorials