Ionic-framework: Badge on ion-tab

Created on 18 Jan 2016  路  10Comments  路  Source: ionic-team/ionic-framework

_From @mauricionarcizo on January 12, 2016 15:46_

How I can add badge on ion-tab?

_Copied from original issue: driftyco/ionic2#935_

Most helpful comment

@RonnieToupal

tabBadge="{{ numItems > 0 ? numItems : '' }}"

All 10 comments

_From @ivks on January 17, 2016 11:41_

+1. Looking for an answer to this question.
@mauricionarcizo One Suggestion:
In case you are not using tabTitle, in tabs. Use it as a badge and style the .tab-button-text class to make it look like one.

This is now possible using the following markup (tabBadgeStyle is optional):

<ion-tab tabTitle="Location" tabIcon="navigate" tabBadge="11" tabBadgeStyle="secondary"></ion-tab>

screen shot 2016-01-23 at 12 45 10 pm

Tried to keep naming consistent with tabIcon and tabTitle. Let me know if you don't like this. @adamdbradley @mhartington

Thank you!

Forgot to check dynamic values. :smile: Can be passed like this:

myBadge:number = 55;

or this:

myBadge:string = "55";

and then on the tab:

<ion-tab tabTitle="Settings" tabIcon="settings" [tabBadge]="myBadge" tabBadgeStyle="primary"></ion-tab>

Examples here:
https://github.com/driftyco/ionic/blob/master/src/components/tabs/test/badges/main.html
https://github.com/driftyco/ionic/blob/master/src/components/tabs/test/badges/app-module.ts

IS there any chance to have two badges ?

This will not be supported. As the design from both platforms do not allow multiple badges to be displayed on the same component

any easy was to hide badge if its 0?

@RonnieToupal

tabBadge="{{ numItems > 0 ? numItems : '' }}"

@brandyscarney any way to have an ios styled badge on android?

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings