Skip to content

Badge

A small, inline label used to display status, counts, or tags.

ApproachWhere it appearsHow to use
@Badge / @Stereotype(FieldStereotype.badge)Inside the form body, inline with other fieldsAnnotate a field
@BadgeInHeader / HeaderBadgesSupplierPage header strip alongside the titleAnnotate a field or implement the interface

Annotating a boolean field with @Badge (shorthand for @Stereotype(FieldStereotype.badge)) renders it as a coloured chip in the form body — lit when true, muted when false.

@ReadOnly @Badge @Label("VIP") boolean vip;

Annotating a field with @BadgeInHeader moves it to the page header strip and hides it from the form layout. See the display annotations for full details.

@BadgeInHeader(label = "VIP", color = "success")
boolean vip;

For runtime-computed badges implement HeaderBadgesSupplier — see metadata suppliers.


new Badge("Active")
PropertyTypeDefaultDescription
textString—Badge text
iconOnLeftString—Icon name rendered before the text
iconOnRightString—Icon name rendered after the text
colorString (a BadgeColor name)normalColor theme
primarybooleanfalseUses the primary colour fill
smallbooleanfalseRenders a smaller badge
pillbooleanfalseRounds the badge into a pill shape
styleString""Inline CSS
cssClassesString""CSS class names
ValueTypical meaning
normalDefault grey
successGreen — positive / active
warningYellow / amber — caution
errorRed — problem / inactive
contrastHigh-contrast for accessibility
// Success pill badge
Badge.builder()
.text("Active")
.color(BadgeColor.success.name())
.pill(true)
.primary(true)
.build()
// Small error badge
Badge.builder()
.text("Failed")
.color(BadgeColor.error.name())
.small(true)
.build()
// With icon
Badge.builder()
.text("Verified")
.iconOnLeft(IconKey.Check.iconName)
.color(BadgeColor.success.name())
.build()

Badges work well inside grid cell renderers or alongside text:

new HorizontalLayout(
new Text("Order #1234"),
Badge.builder().text("Shipped").color(BadgeColor.normal.name()).pill(true).build()
)

See it live in the Explorer: Images, icons, avatars & badges