Class Badge
java.lang.Object
org.apache.juneau.console.widgets.Badge
An overlay badge on a header action (a bell count, for example) or a
BarBadge.
A badge is exactly one of a count badge (count) or a dot badge (dot); it never
carries both. The optional max clamps a large count to tone selects
the badge colour from the shared StatusTone palette. A count is painted with textContent
— never innerHTML.
The tone is serialized as its enum name (e.g. data-juneau-badge-tone attribute. Colours map as:
StatusTone.INFO— blueStatusTone.SUCCESS— greenStatusTone.WARNING— amberStatusTone.ERROR— redStatusTone.NEUTRAL— neutral
Example:
- Since:
- 10.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionA count badge value (mutually exclusive withdot); when set must be>= 0.A dot (presence) badge with no number (mutually exclusive withcount).Optional visually-hidden context for screen readers, e.g.Optional display clamp; a count above this renders as"<max>+" .Optional colour tone;null leaves the badge in its default colour. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Badgecount(int value) Creates a count badge.static Badgedot()Creates a dot (presence) badge with no number.Sets the visually-hidden screen-reader context.max(int value) Sets the display clamp.tone(StatusTone value) Sets the color tone.voidvalidate()Fail-closed bean validation; called by the enclosing bean'svalidate().
-
Field Details
-
count
A count badge value (mutually exclusive withdot); when set must be>= 0. -
dot
A dot (presence) badge with no number (mutually exclusive withcount). -
max
Optional display clamp; a count above this renders as"<max>+" . When set must be>= 1. -
tone
Optional colour tone;null leaves the badge in its default colour. -
label
Optional visually-hidden context for screen readers, e.g."unread notifications" .
-
-
Constructor Details
-
Badge
public Badge()
-
-
Method Details
-
count
Creates a count badge.- Parameters:
value- The count. Must be>= 0.- Returns:
- A new
Badge.
-
dot
Creates a dot (presence) badge with no number.- Returns:
- A new
Badge.
-
tone
Sets the color tone.- Parameters:
value- The tone. Can benull to use the default colour.- Returns:
- This object.
-
max
Sets the display clamp.- Parameters:
value- The clamp. Must be>= 1.- Returns:
- This object.
-
label
Sets the visually-hidden screen-reader context.- Parameters:
value- The label.- Returns:
- This object.
-
validate
Fail-closed bean validation; called by the enclosing bean'svalidate().- Throws:
IllegalArgumentException- If this badge is not well-formed.
-