2

I want to add my own custom images in place of default images provided by ionic3. I am new in Ionic please help me. Searching for solution since 1 week.

tabs.html

    <ion-tabs [selectedIndex]="mySelectedIndex" name="conference">
        <ion-tab [root]="tab1Root" tabsHideOnSubPages="false" tabTitle="Home" tabIcon="home"></ion-tab>
        <ion-tab [root]="tab2Root" tabsHideOnSubPages="false" tabTitle="About" tabIcon="information-circle"></ion-tab>
        <ion-tab [root]="tab3Root" tabsHideOnSubPages="false" tabTitle="Contact" tabIcon="contacts"></ion-tab>
    </ion-tabs>

tabs.ts

    import { Component } from '@angular/core';
    import { NavParams } from 'ionic-angular';
    import { AboutPage } from '../about/about';
    import { ContactPage } from '../contact/contact';
    import { HomePage } from '../home/home';

    @Component({
      templateUrl: 'tabs.html'
    })
    export class TabsPage {

      tab1Root = HomePage;
      tab2Root = AboutPage;
      tab3Root = ContactPage;
      mySelectedIndex: number;

      constructor(navParams: NavParams) {
        this.mySelectedIndex = navParams.data.tabIndex || 0;
      }
    }
Ajay
  • 570
  • 8
  • 17
  • Please refer this https://stackoverflow.com/questions/42386672/ionic-2-use-picture-in-tab-button – Prithivi Raj Nov 07 '17 at 10:15
  • Possible duplicate of [Add Custom Icon in Ionic 2](https://stackoverflow.com/questions/38462885/add-custom-icon-in-ionic-2) – Duannx Nov 08 '17 at 02:54

1 Answers1

0

I have been looking into this for almost 2 hours. You can simply use following snippet.

  <ion-tab 
    [root]="tab1Root" 
    tabIcon="customicon">
   </ion-tab>
ion-icon {
        background-repeat: no-repeat;
        background-position: 50%;
        background-size: contain;
        background-size: 18px;

        &[ng-reflect-name="customicon"] {
            background-image: url('../assets/images/<your-image>.inactive.png');
            &[ng-reflect-is-active="true"] {
                background-image: url('../assets/images/<your-image>.active.png');
            }
        }
}
isaadabbasi
  • 101
  • 5