Badge Styling
Style Variants
The following variants are supported:
| Variant | Description | Supported by |
|---|---|---|
| Uses a solid background | Aura, Lumo |
| Positive/success state | Aura, Lumo |
| Caution/warning state | Aura, Lumo |
| Error/failure state | Aura, Lumo |
| High-contrast neutral | Lumo |
| Show only icon | Aura, Lumo |
| Show only number | Aura, Lumo |
| Visually hide all content | Aura, Lumo |
| 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.
| Variant | Theme name | Usage recommendations |
|---|---|---|
Normal | Default style. Recommended for informational messages. | |
Success |
| Highlight positive outcomes, such as when a task or operation is completed. |
Warning |
| Communicates caution or potential issues that require user attention. |
Error |
| Use the error theme variant to communicate alerts and failures. |
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.
|
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 |
|---|---|
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| 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