Reputation:
I am working on an Angular project and using mat-tabs to display some rendered data on to the html page. Now the problem which I am facing is I have total 8 tabs and its not fitting in the bar when viewed on a laptop screen. Its using pagination to enable me to view other tabs which are not fitting to the screen. If I disable the pagination then just 5 tabs are showing out of 8. I there any way to style so that the remaining columns can be displayed. Attaching a screenshot of the way I am expecting the tabs to be displayed. Any help would be really helpful. Regards
HTML Part
<mat-tab-group [disableRipple]='true' >
<mat-tab label="Overall Status Rollup" class="w3-bar w3-black" style="width: 5%;" >
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;"><h4 [innerHTML]="project['XYZ-2'].assignee"></h4></div>
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-2'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
<mat-tab label="Test Infrastructure & Software">
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;"><h4 [innerHTML]="project['XYZ-2'].assignee"></h4></div>
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-9'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
<mat-tab label="Product Assurance">
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;"><h4 [innerHTML]="project['XYZ-2'].assignee"></h4></div>
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-14'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
<mat-tab label="Test Architecture & Framework">
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;"><h4 [innerHTML]="project['XYZ-2'].assignee"></h4></div>
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-17'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
<mat-tab label="Factory Quality & Test">
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;"><h4 [innerHTML]="project['XYZ-2'].assignee"></h4></div>
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-30'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
<mat-tab label="UDX Roll-up">
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;"><h4 [innerHTML]="project['XYZ-2'].assignee"></h4></div>
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-726'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
<mat-tab label="EOS Roll-up">
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;"><h4 [innerHTML]="project['XYZ-2'].assignee"></h4></div>
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-727'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
<mat-tab label="Data & Project Management">
<div *ngIf="project | async as project; else loading;">
<div style="padding-left:50px;padding-top:50px;" [innerHTML]="project['XYZ-1023'].synopsis"></div>
</div>
<ng-template #loading>Loading User Data...</ng-template>
</mat-tab>
</mat-tab-group>
CSS Part
::ng-deep.mat-tab-header {
background-color: black;
}
::ng-deep.mat-ripple {
color: rgb(5, 214, 5);
font-weight: 700;
}
::ng-deep.mat-tab-link,
::ng-deep.mat-tab-label,
::ng-deep.mat-tab-label-active {
max-width: 13%;
}
::ng-deep.mat-tab-header-pagination {
display: none !important;
}
Upvotes: 1
Views: 6070
Reputation: 4987
Just add this in your main css file:
.mat-tab-links {
flex-flow: wrap;
}
Here is a repro on Stackblitz - wrap mat-tabs-links
The colored bottom bar isn't acting properly but I don't think there is another way of doing this. you can disable it and create your on effect own effect for each links, or create another mat-tabs under the first one.
[Edit] Here is a preview i have of the stackblitz :
Upvotes: 1