Skip to main content

Module badge

Module badge 

Source
Expand description

Corner badges — small notification circles painted over a themed widget.

A Badge is a circle with optional text, anchored to one of the four corners of a widget. Attach it to a Button to signal that the control opens something with unseen content (balance or approval changes, unread messages, …):

let changes = 3;
ui.add(
   Button::new("Balance & approvals")
      .badge(Badge::new(changes.to_string()).corner(BadgeCorner::TopRight)),
);

The badge is an overlay: it is painted on top of the widget and never changes its size or layout. The fill defaults to ThemeColors::error and the text to ThemeColors::bg, matching the theme rule that chromatic fills carry bg-colored glyphs.

Structs§

Badge
A notification circle painted in a corner of a widget.

Enums§

BadgeCorner
Which corner of a widget a Badge is anchored to.