Skip to content

Badge

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

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()
)