Docs

Documentation versions (currently viewingVaadin 25.1 (pre-release))

Badge

Badges are colored text elements containing small bits of information.

Badges are colored text elements containing small bits of information. They’re used for labeling content, displaying metadata and/or highlighting information.

Note
Preview Feature

This is a preview version of Badge. You need to enable it with the feature flag badgeComponent. Preview versions may lack some planned features, and breaking changes may be introduced in any Vaadin version. We encourage you to try it out and provide feedback to help us improve it.

Source code
BadgeBasic.java
badge-basic.tsx
badge-basic.ts

Label

Badges should contain a label. Labels should be clear, concise, and written using sentence case. Aim for 1 to 2 words.

Icons

Badges can contain icons as well as text. Icons are placed before the text using the icon slot.

Source code
BadgeIcons.java
badge-icons.tsx
badge-icons.ts
Note
Use icons sparingly
The benefit of using icons should be weighed against the visual noise it adds.

Icon-Only

Badges can also be used with icons without a label. For accessibility, a tooltip and aria-label attribute is recommended to ensure that all users can identify their meaning.

Source code
BadgeIconsOnly.java
badge-icons-only.tsx
badge-icons-only.ts

Icon-only badges should primarily be used for common recurring content with highly standardized, universally understood icons (such as a checkmark for "yes"), and for content that’s repeated, for example in lists and tables.

Source code
BadgeIconsOnlyTable.java
badge-icons-only-table.tsx
badge-icons-only-table.ts

Number

Badges can display a numeric value using the number property. This is useful for showing counts, such as unread messages or notifications. When both text content and a number are set, both are displayed.

Source code
BadgeNumber.java
badge-number.tsx
badge-number.ts

Use Cases

Highlighting and Distinguishing Information

A typical use case for badges is to highlight an item’s status, for example in a Grid.

Source code
BadgeHighlight.java
badge-highlight.tsx
badge-highlight.ts

They are also often used for displaying metadata tags.

Interactive Content

Badges can house interactive content such as Anchors and Buttons. For example, Badges that highlight active filters might contain a "Clear" Button which removes the associated filter.

Source code
BadgeInteractive.java
badge-interactive.tsx
badge-interactive.ts

Counter

Badges can be used as counters, for example to show the number of unread/new messages, selection count, etc.

Source code
BadgeCounter.java
badge-counter.tsx
badge-counter.ts

Assistive technologies, such as screen readers, interpret badges solely based on their content. Without proper context, they may end up confusing the user. To provide context for people using screen readers, set the badge’s aria-label attribute.

Best Practices

Badge vs Button

Badges and Buttons are similar in appearance. This might lead users to think that badges are interactive.

Placement, language, and color can all help mitigate any confusion. First, badges shouldn’t be labeled with active verbs. They aren’t actions, but rather static text/content. Second, avoid placing badges directly next to Buttons, in particular if they are using similar themes.

Caution
Deprecated: Theme-Based Badge
Earlier Vaadin versions used a theme-based approach where badges were created by applying theme="badge" to HTML elements. This approach is deprecated. See the Vaadin 24 documentation for details on the theme variant usage.

69AF8882-CA67-4AB8-BF9F-69A1EA6CE84C