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 / BadgeSupplierPage 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 BadgeSupplier — see metadata suppliers.


new Badge("Active")
PropertyTypeDefaultDescription
textStringBadge text
iconOnLeftStringIcon name rendered before the text
iconOnRightStringIcon name rendered after the text
colorBadgeColornormalColor 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
infoBlue — informational
contrastHigh-contrast for accessibility
// Success pill badge
Badge.builder()
.text("Active")
.color(BadgeColor.success)
.pill(true)
.primary(true)
.build()
// Small error badge
Badge.builder()
.text("Failed")
.color(BadgeColor.error)
.small(true)
.build()
// With icon
Badge.builder()
.text("Verified")
.iconOnLeft(IconKey.Checkmark.iconName)
.color(BadgeColor.success)
.build()

Badges work well inside grid cell renderers or alongside text:

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