ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Badge on ion-tab

Open mhartington opened this issue 10 years ago • 10 comments

From @mauricionarcizo on January 12, 2016 15:46

How I can add badge on ion-tab?

Copied from original issue: driftyco/ionic2#935

mhartington avatar Jan 18 '16 20:01 mhartington

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.

mhartington avatar Jan 18 '16 20:01 mhartington

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

brandyscarney avatar Jan 23 '16 17:01 brandyscarney

Thank you!

mauricionarcizo avatar Jan 23 '16 19:01 mauricionarcizo

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

brandyscarney avatar Jan 23 '16 19:01 brandyscarney

IS there any chance to have two badges ?

ghaliano avatar Sep 29 '16 14:09 ghaliano

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

mhartington avatar Sep 29 '16 14:09 mhartington

any easy was to hide badge if its 0?

RonnieToupal avatar Nov 30 '16 03:11 RonnieToupal

@RonnieToupal

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

marticrespi avatar Dec 11 '16 17:12 marticrespi

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

mdanics avatar Aug 23 '18 20:08 mdanics

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.

ionitron-bot[bot] avatar Sep 22 '18 20:09 ionitron-bot[bot]