nicegui icon indicating copy to clipboard operation
nicegui copied to clipboard

Provide ui.badge element

Open rodja opened this issue 2 years ago • 1 comments

@hroemer showed in #101 how Quasar badges could be used in custom code. We would like to see a NiceGUI element ui.badge(text='badge content'). As the Quasar examples show, a badge can be attached to buttons, labels etc. So these elements should derive from nicegui.elements.Group to write something like

with ui.button('my button', on_click=lambda: badge.set_text(int(badge.text) + 1)):
    badge = ui.badge('0')

which should count the button clicks in the badge.

rodja avatar Oct 06 '22 13:10 rodja

@hroemer do you have a rough time estimate for this? We would love to see this feature in the next release.

rodja avatar Oct 22 '22 05:10 rodja

@rodja I created #146 implementing ui.badge as requested. I also changed element ui.button as proposed but left other elements such as ui.label as is. This should be better addressed in a separate issue.

hroemer avatar Nov 04 '22 11:11 hroemer

@hroemer Thanks for your PR! Besides minor cleanup I managed to remove _QBadge again. Although there is no text property in jp.QBadge, we can simply bind against label.

https://github.com/zauberzeug/nicegui/commit/8ff156b368313ad9b0d025eb38dda66a01a2506c

falkoschindler avatar Nov 07 '22 07:11 falkoschindler