ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.09k stars 13.51k forks source link

feat: control badge positioning on icon within ion-button #18736

Open hwasoocho opened 5 years ago

hwasoocho commented 5 years ago

Feature Request

Ionic version: [x] 4.x

Describe the Feature Request ion-button with slottable ion-badge to indicate notifications.

Describe Preferred Solution ion-tab-button already has this. From the doc:

<ion-tab-button tab="schedule">
  <ion-icon name="calendar"></ion-icon>
  <ion-label>Schedule</ion-label>
  <ion-badge>6</ion-badge>
</ion-tab-button>

Describe Alternatives Reference to how this can be done currently: https://forum.ionicframework.com/t/how-to-add-a-badge-to-a-icon-inside-a-ion-button/70868/3

liamdebeasi commented 5 years ago

Thanks for the issue! I put together a code pen on how this can be done with ion-button: https://codepen.io/liamdebeasi/pen/MMZyJq.

Does the example provided in my CodePen work for your use case? Thanks!

hwasoocho commented 5 years ago

Hi thanks for the prompt reply!

Sorry, I must've been ambiguous with my original request. Please refer to the screenshot below.

Screenshot_20190709-155226_Chrome

I was thinking something more like the icon-only navbar button shown at top-right which essentially mirrors what Ionic already has with ion-tab-button shown at bottom-left.

robingenz commented 4 years ago

Any progress? Would love to see that.

bleuscyther commented 4 years ago

Nice feature to have

gmtns commented 4 years ago

that would be great. waiting for news... 😄

troywweber7 commented 2 years ago

This is especially important if buttons are used in a top navigational toolbar, for example.

infacto commented 1 year ago

In my opinion Ionic should have it. For buttons in the toolbar or tab nav etc. Maybe just a slot for this component? Badge with and without a value.

button-icon-with-badge-number

button-icon-with-badge

It's also a part in Material Design: https://m2.material.io/develop/android/supporting/badge https://m3.material.io/components/badges

image

My current workaround is to use data-badge on ion-button and style with ::after content attr. Intead of using ion-badge. Works fine. But it would be great if this is an official feature.