How to dynamically change the color of ion-tabs


Hi, I like to know how to change the color of the ion-tab only in the active state.By using the color code from the JSON response.


<ion-tabs [color]="jsonColorField ? 'jsonColorField' : 'defaultColor'">

If not what you need, kindly elaborate the question…


Thank for the reply.

    <ion-tab tabIcon="contact" [root]="tab1"></ion-tab>
    <ion-tab tabIcon="compass" [root]="tab2"></ion-tab>
    <ion-tab tabIcon="analytics" [root]="tab3"></ion-tab>
    <ion-tab tabIcon="settings" [root]="tab4"></ion-tab>

I want to change the active state color of the tabIcon. I can change the active state Icon color using .tabs-ios .tab-button[aria-selected=true]{ color: #fff}. But I want to change the color dynamically from the JSON response.


Did you try the above ? You’ll just need to make sure that you map the right json field to the color attr.


I tried the solution

<ion-tabs id="tabsBar" [color]="1==0 ? themecolour : defaultColor">
but I gets the ion-tab like this
<ion-tabs id="tabsBar" class="tabs tabs-ios tabs-ios-#ff00ff" tabsplacement="bottom" tabslayout="icon-top" tabshighlight="false"></ion-tabs>