Is it possible to change the inkbar color of the active tab?
By default the ink bar is blue. See here for an example.
I tried this in SCSS, but it doesn't work.
.mat-tab-label-container{
.mat-tab-list{
.mat-ink-bar {
background-color: green
}
}
}
.mat-tab-label-active{
color: green
}
Anyone can please help,
<mat-tab-group> Attributes : backgroundColor and color backgroundColor: Background color of the tab group. color: Underline color for active tab. The theme colors that can be assigned to above both attributes are 'primary', 'accent' and 'warn'.
Material tabs (with matTabContent ) are rendering multiple instances of the tab body inside the same tab when switching away and back too fast.
The solution 🕶 First, we need to add a click listener on the mat-tab-group and disable all tabs because if tabs are not disabled then the user will be able to navigate on them and we want to navigate on tabs conditionally not manually.
Please see this link ( Cannot style mat-tab without ::ng-deep and !important ) and upvote if it helps you, I think this is similar to what you want to achieve.
You need to use Selector specificity and then put your style in the root style /src/styles.css (NOTE: that don't put it in the components styleUrls your style will not work)
to style the ink bar
.mat-tab-group.mat-primary .mat-ink-bar, .mat-tab-nav-bar.mat-primary .mat-ink-bar{
background: yellow;
height: 10px;
}
You can try this code to make it elliptical to cover the item.
/* label style */
.mat-tab-label{
background: #e7e7e7;
color: black;
min-width: 60px!important;
}
/* focus style */
.mat-tab-group.mat-primary .mat-tab-label:not(.mat-tab-disabled):focus, .mat-tab-group.mat-primary .mat-tab-link:not(.mat-tab-disabled):focus, .mat-tab-nav-bar.mat-primary .mat-tab-label:not(.mat-tab-disabled):focus, .mat-tab-nav-bar.mat-primary .mat-tab-link:not(.mat-tab-disabled):focus{
background: #e7e7e7;
}
/* ink bar style */
.mat-tab-group.mat-primary .mat-ink-bar, .mat-tab-nav-bar.mat-primary .mat-ink-bar{
background: rgba(149, 165, 166,0.3);
height: 35px;
border-radius: 100px;
margin-bottom: 5px;
}
Please see the live sample here.
https://stackblitz.com/edit/dmgrave-ng-so-anser-tabs-style?file=styles.css
Hope this helps.
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