Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Material Design : Different colors for different tabs in md-tabs

Is there a way to set different background colors for different tabs in md-tabs ? The default is no color as can be seen in tabs demo

I tried <md-tabs background-color="green"> but it's not working

like image 313
Saurabh Verma Avatar asked Feb 09 '23 23:02

Saurabh Verma


2 Answers

AngularJS Material design (md) tabs, md-tabs background color is transparent and uses the background color of your main container. Try to add CSS class for md-tabs .

Added background to entire md-tabs

md-tabs {
    background: red;
    border: 1px solid #e1e1e1; }

enter image description here

By adding CSS childs to md-tab class, you can see different colors for different tabs.

 .md-tab:first-child{background: green; } 
 .md-tab:nth-child(2){background: pink; } 
 .md-tab:nth-child(3){background: blue; } 

enter image description here

fiddle https://jsfiddle.net/cxf3otz9/

codepen http://codepen.io/anon/pen/zGNEyw

like image 167
Prime Avatar answered Feb 13 '23 06:02

Prime


Upon evaluating source code, i came to there a way to achieve dynamic content formatting for tab titles. To get that, please write the code as below

<md-tabs>
    <md-tab>
        <md-tab-label>
            <span ng-class="......">
                Title
            </span>
        </md-tab-label>
        <md-tab-body>
        content
        </md-tab-body>
    </md-tab>
</md-tabs>
like image 40
Pravin Avatar answered Feb 13 '23 07:02

Pravin