Manoj Shrestha
Manoj Shrestha

Reputation: 4684

Ionic 4: How to set border to the selected ion-tab-button?

I tried applying the following css but didn't work.

*.scss

ion-tab-button[aria-selected=true] {
   border-top: 1px solid blue;
}

*.html

<ion-tabs>
  <ion-tab-bar slot="bottom">
    <ion-tab-button tab="schedule">
      <ion-icon name="calendar"></ion-icon>
      <ion-label>Schedule</ion-label>
    </ion-tab-button>
    ...
    <ion-tab-button tab="about">
      <ion-icon name="information-circle"></ion-icon>
      <ion-label>About</ion-label>
    </ion-tab-button>
  </ion-tab-bar>
</ion-tabs>

Upvotes: 2

Views: 3564

Answers (2)

Manoj Shrestha
Manoj Shrestha

Reputation: 4684

I found that applying the box-shadow instead of border worked.

ion-tab-button[aria-selected=true] {
  box-shadow: 0 2px 0 0 blue inset;
}

Upvotes: 3

benra
benra

Reputation: 396

Use ion-segment like this. It will look like a tab button.

<ion-footer>
  <ion-toolbar>
    <ion-segment>
      <ion-segment-button value="all" checked>
        All
      </ion-segment-button>
      <ion-segment-button value="favorites">
        Favorites
      </ion-segment-button>
    </ion-segment>
  </ion-toolbar>
</ion-footer>

Upvotes: 1

Related Questions