How to change header color of ion-menu, without changing color of ion-navbar?

1.2k views Asked by At

I have this below code for ion navbar, where I am having one menu icon on the right side. And I want to change the color of that menu header.But when i am changing color of ion-navbar , it is changing for menu header also.I want separate color for both ion-navbar and ion-menu.

<ion-menu [content]="content" side="right" id="menu2">
    <ion-header>
        <ion-toolbar class="menu_header">
            <ion-title>MyApp</ion-title>
        </ion-toolbar>
    </ion-header>
    <ion-content>
        <ion-list no-lines>
             <button ion-item  menuClose="menu2" detail-none>
              Item1
            </button>
            <button ion-item  menuClose="menu2" detail-none>
                Item2
            </button>
        </ion-list>
    </ion-content>
</ion-menu>
<ion-header>
    <ion-navbar primary>
        <ion-title class="header-title" text-center>
            Home
        </ion-title>
        <button ion-button icon-only menuToggle="right" end >
            <ion-icon name="menu"></ion-icon>
        </button>
    </ion-navbar>
</ion-header>

And for changing the color of ion-navbar I am adding the below line in variable.scss

$toolbar-background: #EF473A;

Can anyone please help me how to keep the separate color for both?

1

There are 1 answers

5
Th3S4mur41 On

If you want to change the color only for the titles, you could use the classes

.header-title {
  color: blue;
}
.menu_header {
  color: #EF473A;
}

If you'd like to change the color for the whole header You can either do it on the element:

body > ion-header {
  color: blue;
}
ion-menu > ion-header {
  color: #EF473A;
}

or alternatively add a class to the elements you want to modify, but that potentially mean editing a third party component...