Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the background color of the navbar in Ionic 2?

I'm trying to change the navbar background color in Ionic 2. I have tried many things, like class="bar bar-stable" etc

Right now my code looks like this:

<ion-navbar  *navbar> 

So the background is currently grey (default)

like image 301
Tyler Ruby Avatar asked Dec 04 '15 07:12

Tyler Ruby


4 Answers

from ionic 2 you can add custom style in your src/theme/variables.scss file

enter image description here

And then add the class where you want

enter image description here

enter image description here

Now see the result

enter image description here

Reference : Theming your Ionic App

like image 101
Sanjoy Kanrar Avatar answered Nov 15 '22 19:11

Sanjoy Kanrar


The navbar got its own styles. SO you need to overwrite it.

.toolbar-background {
  background-color: #0c60ee;
}
like image 39
CESCO Avatar answered Nov 15 '22 20:11

CESCO


For Ionic 2 : try this

in ionic 1 u can do in this way. look here:Ionic header

other way

css :

.theme-color {
background-color: ##009688 !important;
color: #ffffff;}

html:

   <ion-nav-bar class="theme-color"><ion-nav-bar>

hope this helpful to you.

like image 4
the_mahasagar Avatar answered Nov 15 '22 19:11

the_mahasagar


Right now (rc4) the correct way to do this is to change the /src/themes/variables.scss file, and add:

$toolbar-background: blue;

This effectively changes the color for wherever the value is used. More info here

like image 3
veljkoz Avatar answered Nov 15 '22 19:11

veljkoz