You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just use <ion-badge>, doesn't that work for you?
I tried it with the tabs starter project. It doesn't seem to work well. After viewing the result, I get the feeling the designers didn't plan for it because it doesn't look right. The badge is jammed against the icon with no margin or spacing. I can add spacing with css but i don't usually need to do this for badges. They normally just work.
I think we need to hear from the team the official word on using badges in tab buttons and update the documentation accordingly.
Sean, are you saying that I can choose a slot like 'end' when including a badge? The docs for ion-tab-button and ion-tab say there aren't any slots for these components.
I tried specifying a slot and the badge disappears.
Ok, but it doesn't work well. The badge gets jammed against the icon. I can use css to move it farther away but it seems like the default slot should obviate that. Seems broken based on the appearance.
I think the docs should be updated for any component that has a 'default' slot. I wasn't aware that such a thing existed nor how it works. Maybe I missed that.
Probably would be a good idea to update the docs for ion-tabs to cover the use of badges since it is such a common use case and it's not obvious how to do it. I've spoken to other devs who didn't know how it works.
Thank you for submitting the issue! Glad to hear that it's been resolved! I'll be moving this issue over to the docs repo though. It would be great to add a section to show how to use badges in the tab bar.
Activity
EinfachHans commentedon Jun 19, 2024
I just use
<ion-badge>, doesn't that work for you?donhmorris commentedon Jun 19, 2024
I tried it with the tabs starter project. It doesn't seem to work well. After viewing the result, I get the feeling the designers didn't plan for it because it doesn't look right. The badge is jammed against the icon with no margin or spacing. I can add spacing with css but i don't usually need to do this for badges. They normally just work.
I think we need to hear from the team the official word on using badges in tab buttons and update the documentation accordingly.
sean-perkins commentedon Jun 20, 2024
I am no longer on the team, but
ion-badgeis the correct/intended component for this usage.ion-tab-buttonhas specific styling targeting when anion-badgeis slotted: https://github.com/ionic-team/ionic-framework/blob/ff214bd5f3da947d861d5d0b81575791c391a9b8/core/src/components/tab-button/tab-button.ios.scss#L16-L28Since the element is slotted, badge's position can be customized through CSS in the light dom.
donhmorris commentedon Jun 20, 2024
Sean, are you saying that I can choose a slot like 'end' when including a badge? The docs for ion-tab-button and ion-tab say there aren't any slots for these components.
I tried specifying a slot and the badge disappears.
`
Tab 1 5sean-perkins commentedon Jun 20, 2024
ion-tab-buttonsupports a single/default slot: https://github.com/ionic-team/ionic-framework/blob/ff214bd5f3da947d861d5d0b81575791c391a9b8/core/src/components/tab-button/tab-button.tsx#L179e.g.:
The styling shared earlier will target the badge and position it absolutely in the container.
donhmorris commentedon Jun 20, 2024
Ok, but it doesn't work well. The badge gets jammed against the icon. I can use css to move it farther away but it seems like the default slot should obviate that. Seems broken based on the appearance.

sean-perkins commentedon Jun 20, 2024
Ionicons are not of a consistent viewbox, so you will need to manually position your badge if you want a specific visual appearance.
Ionic Framework tries to closely resemble the visual appearance of the iOS tab bar: https://developer.apple.com/documentation/swiftui/tabview
donhmorris commentedon Jun 20, 2024
I can live with that.
donhmorris commentedon Jun 20, 2024
I think the docs should be updated for any component that has a 'default' slot. I wasn't aware that such a thing existed nor how it works. Maybe I missed that.
Probably would be a good idea to update the docs for ion-tabs to cover the use of badges since it is such a common use case and it's not obvious how to do it. I've spoken to other devs who didn't know how it works.
Thanks for commenting.
thetaPC commentedon Mar 13, 2025
Thank you for submitting the issue! Glad to hear that it's been resolved! I'll be moving this issue over to the docs repo though. It would be great to add a section to show how to use badges in the tab bar.
thetaPC commentedon Mar 18, 2025
The new playgrounds will be on the site very soon! You'll find them under the
ion-badgeandion-tab-barpages.