Cannot customize style of md-tabs
Bug, feature request, or proposal:
Adding custom style to the tabs header
What is the expected behavior?
affect css style of header (font size, color, display....)
What is the current behavior?
Style is beeing totally ignored due to attribute selectors generated by the own element ignoring the styleUrls ones
What are the steps to reproduce?
Create a simple element (html):
<md-tab-group>
<md-tab>
<template md-tab-label>Personal info</template>
<template md-tab-content>
<h4>Name, address</h4>
<div class="">
Some data here
</div>
</template>
</md-tab>
<md-tab>
<template md-tab-label>Payment</template>
<template md-tab-content>
<div class="">
Payment setup
</div>
</template>
</md-tab>
</md-tab-group>
Add this style in the .scss:
md-tab-group {
.md-tab-header {
font-size: 12px !important;
display: flex;
flex-flow: row wrap;
align-items: center;
.md-tab-label {
flex: 1;
min-width: 1px;
}
}
}
Plunk demo http://plnkr.co/edit/K1iVNV
What is the use-case or motivation for changing an existing behavior?
Need to customize md tabs style/colors/responsive
Which versions of Angular, Material, OS, browsers are affected?
Angular 2.0, Material alpha 8-2
Is there anything else we should know?
Hello, it works indeed as @ivanntis said. But even if I can change all of the tabs, how can I change only one tab style? I want to add a + at the end in order to add a tab. Thank you.
Already mentioned, but I see a few adopting the /deep/ solution. /deep/ is being deprecated, sooner or later your apps will break.
So what is the best solution?
@mist3r3 the choices you have are as reported by @andrewseguin earlier in this thread. Since /deep/ is being deprecated the solutions you are left with are (copied from @andrewseguin above):
(1) Set view encapsulation to NONE on the component that hosts your tabs and use your component style sheet (2) Load a separate style sheet apart from Angular (e.g. through index.html) that affects the tabs
Personally I use option 1.
The issue with (1) setting the view encapsulation to NONE is those styles bleed throughout the entire app. If my component's stylesheet I had h1 { color: blue } then when changing the component from Emulated to None it makes ALL h1 elements blue that don't have a color defined by a more specific rule.
I would like to say "make this component and all it's children" h1's blue. Setting encapsulation to none I would have to add an application-wide unique selector to my component and use that in the component's stylesheet. But that's what I'm trying to get away from doing and why I fell in love with component view encapsulation.
@anderflash i did the same thing! i wrapped it into a css class e.g --> class ="test" --> test{ /deep/ md-checkbox .md-checkbox-inner-container{ margin:..; } }
and its works!
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.