Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic tabs Badge

I am trying to add a badge on my Icons in the tabs. The current result is: http://play.ionic.io/app/decfc14cb171

Does anyone know how to put them in the top-right corner of each icon?

I tried using but it proved more problematic in other aspects, although with the "badge" attribute is was easier to achieve the desired effect. Is there a way to replicate it without using ion-tabs?

like image 466
galgo Avatar asked Sep 04 '15 22:09

galgo


People also ask

How do I add badges to icon ionic?

Starting out, open the page you would like to add the Badge Notification to. Once you have opened the file you would like to use it on, add the following to the import section of your file. import { Badge } from '@ionic-native/badge/ngx'; In the Constructor, add private badge: Badge to the list.

What is Ion badge?

shadow. Badges are inline block elements that usually appear near another element. Typically they contain a number or other characters. They can be used as a notification that there are additional items associated with an element and indicate how many items there are.

How do you add tabs in ionic?

Adding Tabs Bar in Ionic Application The tab navigation is created by adding the ion-tabs having ion-tab-bar inside it which creates a tab bar on position defined in the slot property. Each tab button is created using the ion-tab-button with tab property which is the path of tab page resulting navigation.

How do you use ionic ion-tabs?

Activating Tabs​Each ion-tab-button will activate one of the tabs when pressed. In order to link the ion-tab-button to the ion-tab container, a matching tab property should be set on each component. The ion-tab-button and ion-tab above are linked by the common tab property.


1 Answers

In the latest Ionic doc appears a different way of doing this:

Using the tabBadget and tabBadgetStyle attributes in the tab code, like this:

 <ion-tabs>
      <ion-tab tabIcon="call" [root]="tabOne" tabBadge="3" tabBadgeStyle="danger"></ion-tab>
      <ion-tab tabIcon="chatbubbles" [root]="tabTwo" tabBadge="14" tabBadgeStyle="danger"></ion-tab>
      <ion-tab tabIcon="musical-notes" [root]="tabThree"></ion-tab>
    </ion-tabs>

where it says "danger" is the color that you define in the Theme...

Hope it helps the new ones coming to find answer in 2017!

like image 99
Ari Waisberg Avatar answered Oct 22 '22 11:10

Ari Waisberg