How to change the background color of tab bar and tab icon in Ionic 4

谁说胖子不能爱 提交于 2019-12-11 06:56:22

问题


I want to know how to change the background color of this tab bar as Ionic 4.

I tried to add the --background: white; in ion-tab/ion-tabs but it doesn't work.

<ion-tabs>
  <ion-tab label="Home" icon="home" href="/tabs/(home:home)">
    <ion-router-outlet name="home"></ion-router-outlet>
  </ion-tab>
  <ion-tab label="About" icon="information-circle" href="/tabs/(about:about)">
    <ion-router-outlet name="about"></ion-router-outlet>
  </ion-tab>
  <ion-tab label="Contact" icon="contacts" href="/tabs/(contact:contact)">
    <ion-router-outlet name="contact"></ion-router-outlet>
  </ion-tab>
</ion-tabs>

I'm so curious about this new Ionic 4 :( Please help...


回答1:


You need to add properties called color. Ionic 4 has predefined colors:

  • primary
  • secondary
  • tertiary

More info in documentation

Sample usage:

<ion-tabs main color="primary">




回答2:


Give ion-tab a class name like

<ion-tab class="tab"></ion-tab>

Now in the scss file provide the background-color for the class named tab

.tab{
   background-color: white;
}



回答3:


Ionic 4+

ion-tab-bar, ion-tab-button{
 background-color: #ce0013;
}

ion-icon{
  color: #d7d8da;
}



来源:https://stackoverflow.com/questions/53114684/how-to-change-the-background-color-of-tab-bar-and-tab-icon-in-ionic-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!