Reputation: 1409
I am following tutorial to put md-tabs
in the md-toolbar
from here. But, My selected indicator tab is same color as the md-primary
which make it invisible. Please see the image below.
But, when I change the color of the md-tabs
to md-accent
, it will show the indicator.
How do I change the color of the selected indicator tab?
Here is the code:
<md-toolbar class="md-whiteframe-5dp">
<div class="md-toolbar-tools">
<h2>Title</h2>
</div>
<md-tabs md-selected="tabs.selectedIndex">
<md-tab id="tab1" aria-controls="tab1-content">Tab #1</md-tab>
<md-tab id="tab2" aria-controls="tab2-content">Tab #2</md-tab>
<md-tab id="tab3" aria-controls="tab3-content">Tab #3</md-tab>
</md-tabs>
</md-toolbar>
<md-content layout-padding flex>
<ng-switch on="tabs.selectedIndex" class="tabpanel-container">
<div role="tabpanel" id="tab1-content" aria-labelledby="tab1" ng-switch-when="0" md-swipe-left="tabs.next()" md-swipe-right="tabs.previous()">
View for Item #1<br />
data.selectedIndex = 0
</div>
<div role="tabpanel" id="tab2-content" aria-labelledby="tab2" ng-switch-when="1" md-swipe-left="tabs.next()" md-swipe-right="tabs.previous()">
View for Item #2<br />
data.selectedIndex = 1
</div>
<div role="tabpanel" id="tab3-content" aria-labelledby="tab3" ng-switch-when="2" md-swipe-left="tabs.next()" md-swipe-right="tabs.previous()">
View for Item #3<br />
data.selectedIndex = 2
</div>
</ng-switch>
</md-content>
By the way, all the color are default.
Upvotes: 20
Views: 29645
Reputation: 839
Bit late to the party but might help someone. Simply put color property of the mat-tab-group to none
<mat-tab-group mat-align-tabs="start" mat-align-tabs="center" color="none">
Upvotes: 3
Reputation: 31
CSS
.mat-tab-group.mat-primary .mat-ink-bar, .mat-tab-nav-bar.mat-primary .mat-ink-bar {
background-color: #f44336;
}
Upvotes: 2
Reputation: 915
After much wasted time reading responses that just didn't work, this is the solution I have found. Being new to CSS, and as someone that despises CSS, I thought I would post my solution for those that also are new to CSS and despise CSS.
HTML
<md-tab-group>
<md-tab>
<ng-template md-tab-label>
<span class="mdTab">Tab Label</span>
</ng-template>
</md-tab>
</md-tab-group>
CSS
.mdTab{
color: white;
}
Upvotes: 0
Reputation: 5592
You need to define a custome theme and set the accent-color to the one that you want your md-ink-bar to have. In this example it's white:
var customAccent = {
'50': '#b3b3b3',
'100': '#bfbfbf',
'200': '#cccccc',
'300': '#d9d9d9',
'400': '#e6e6e6',
'500': '#f2f2f2',
'600': '#ffffff',
'700': '#ffffff',
'800': '#ffffff',
'900': '#ffffff',
'A100': '#ffffff',
'A200': '#fff',
'A400': '#f2f2f2',
'A700': '#ffffff'
};
$mdThemingProvider
.definePalette('whiteAccent', customAccent);
$mdThemingProvider.theme('whiteAccentTheme')
.primaryPalette('deep-purple')
.accentPalette('whiteAccent');
You can generate an accent-palette on this site: https://angular-md-color.com/#/
In your view, use the new custom theme for your md-tabs:
<div md-theme="whiteAccentTheme">
<md-tabs class="md-primary">...</md-tabs>
</div>
Upvotes: 2
Reputation: 643
I had struggle with this issue, too. I don't like the solution to overwrite the CSS. So there is a a much more convenient and more straight forward solution:
Just set the default HUE for your palette:
$mdThemingProvider.theme('default')
.primaryPalette('amber', { 'default': '600'})
.accentPalette('indigo', { 'default': '400'});
The tab ink bar, the FAB speedial, ... will use this color from your palette.
Upvotes: 1
Reputation: 428
md-tabs md-ink-bar {
color: green;
background-color: green;
}
Upvotes: 8
Reputation: 2062
The simplest way is to change via CSS :
md-tabs.md-default-theme md-ink-bar, md-tabs md-ink-bar {
color: red !important;
background-color:red !important;
}
But you can also check the § about theming in the documentation : https://material.angularjs.org/latest/Theming/01_introduction
Sometime the CSS is embedded and generated on the fly in style-tags, if this code doesn't work, try to force the color with !important
.
Upvotes: 32