Docs

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

Badge Styling

Styling API reference for the Badge component.

Style Variants

The following variants are supported:

Variant Description Supported by

filled

Uses a solid background

Aura, Lumo

success

Positive/success state

Aura, Lumo

warning

Caution/warning state

Aura, Lumo

error

Error/failure state

Aura, Lumo

contrast

High-contrast neutral

Lumo

icon-only

Show only icon

Aura, Lumo

number-only

Show only number

Aura, Lumo

dot

Visually hide all content

Aura, Lumo

small

Renders a more compact badge

Aura, Lumo

Color

Badges have four different color variants: default, success, warning, and error. The color variants can be paired with the filled theme variant for additional emphasis.

Source code
BadgeColor.java
badge-color.tsx
badge-color.ts
Variant Theme name Usage recommendations

Normal

Default style. Recommended for informational messages.

Success

success

Highlight positive outcomes, such as when a task or operation is completed.

Warning

warning

Communicates caution or potential issues that require user attention.

Error

error

Use the error theme variant to communicate alerts and failures.

Filled

filled

Used for important information and/or to draw more attention to your badge. Can be combined with all other theme variants.

Note
Accessibility
Assistive technologies, such as screen readers, interpret badges solely based on their content. Without proper context, they may end up confusing the user. If you are using colors and icons to convey information, provide the same info via aria-label to ensure that screen readers can interpret the information.

Dot

The dot theme variant visually hides all the badge content, while keeping it accessible for screen readers.

Source code
BadgeDot.java
badge-dot.tsx
badge-dot.ts

Style Properties

The following style properties can be used in CSS stylesheets to customize the appearance of this component.

To apply values to these properties globally in your application UI, place them in a CSS block using the html {…​} selector. See Component Style Properties for more information on style properties.

Property Supported by

--vaadin-badge-background

Aura, Lumo

--vaadin-badge-border-color

Aura, Lumo

--vaadin-badge-border-radius

Aura, Lumo

--vaadin-badge-border-width

Aura, Lumo

--vaadin-badge-font-family

Aura, Lumo

--vaadin-badge-font-size

Aura, Lumo

--vaadin-badge-font-weight

Aura, Lumo

--vaadin-badge-gap

Aura, Lumo

--vaadin-badge-line-height

Aura, Lumo

--vaadin-badge-padding

Aura, Lumo

--vaadin-badge-text-color

Aura, Lumo

CSS Selectors

The following CSS selectors can be used in stylesheets to target the various parts and states of the component. See the Styling documentation for more details on how to style components.

Important
Not for Shadow DOM
These selectors should be used in styles.css or another stylesheet loaded with the @StyleSheet annotation or the @import CSS rule. They do not work in the shadow DOM of Vaadin components, such as in stylesheets in the components sub-folder or loaded with the @CssImport annotation’s themeFor property.

Root element

vaadin-badge

States

Has icon

vaadin-badge[has-icon]

Has content

vaadin-badge[has-content]

Has number

vaadin-badge[has-number]

Parts

Icon

vaadin-badge::part(icon)

Content

vaadin-badge::part(content)

Number

vaadin-badge::part(number)