nicegui
nicegui copied to clipboard
Provide ui.badge element
@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.
@hroemer do you have a rough time estimate for this? We would love to see this feature in the next release.
@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 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