Skip to content

Commit 969ecaa

Browse files
feat: adding badge to tab header (#800)
* feat: adding badge to tab header
1 parent bf0e0dd commit 969ecaa

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

projects/components/src/tabs/content/tab-group.component.scss

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,25 @@
7575
.tab-label {
7676
flex: 1;
7777
display: flex;
78-
flex-direction: column;
79-
justify-content: center;
80-
text-align: center;
78+
flex-direction: row;
79+
align-items: center;
80+
81+
.tab-badge {
82+
@include font-label($gray-5);
83+
display: flex;
84+
justify-content: center;
85+
text-align: center;
86+
margin-left: 6px;
87+
padding: 0 6px;
88+
height: 16px;
89+
background-color: $gray-2;
90+
border-radius: 8px;
91+
92+
&.active {
93+
background-color: $gray-9;
94+
color: white;
95+
}
96+
}
8197
}
8298

8399
.ink-bar {

projects/components/src/tabs/content/tab-group.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import { TabComponent } from './tab/tab.component';
1010
<mat-tab-group animationDuration="0ms" disableRipple (selectedTabChange)="this.activeTabIndex = $event.index">
1111
<mat-tab *ngFor="let tab of this.tabs; index as i">
1212
<ng-template mat-tab-label>
13-
<div class="tab-label">{{ tab.label }}</div>
13+
<div class="tab-label">
14+
{{ tab.label }}
15+
<div *ngIf="tab.badge" [ngClass]="{ active: activeTabIndex === i }" class="tab-badge">
16+
{{ tab.badge }}
17+
</div>
18+
</div>
1419
<div class="ink-bar" [ngClass]="{ active: activeTabIndex === i }"></div>
1520
</ng-template>
1621
<ng-template matTabContent>

projects/components/src/tabs/content/tab/tab.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ import { ContentHolder, CONTENT_HOLDER_TEMPLATE } from '../../../content/content
1010
export class TabComponent extends ContentHolder {
1111
@Input()
1212
public label!: string;
13+
14+
@Input()
15+
public badge?: string;
1316
}

0 commit comments

Comments
 (0)