Docs

Documentation versions (currently viewingVaadin 14)

You are viewing documentation for an older Vaadin version. View latest documentation

Lumo Badges

Indicate status or other types of supplementary information using badges.

To use the badge utility, you first need to import the style sheet into the correct style scope where you want to use it.

In server-side views (Java), import the JavaScript module using the @JsModule annotation and then import the style sheet it defines by using the @CssImport annotation.

@JsModule("@vaadin/vaadin-lumo-styles/badge.js")
// Here, we add the style sheet to the global scope
@CssImport(include = "lumo-badge")

In client-side views (JavaScript), import the JavaScript module and then include the style sheet it defines by using the <custom-style> element from the Polymer library.

import '@vaadin/vaadin-lumo-styles/badge.js';
import '@polymer/polymer/lib/elements/custom-style.js';

const style = document.createElement('custom-style');
style.innerHTML = `<style include="lumo-badge"></style>`;
// Add the style element to the correct style scope.
// Here we add it to the global scope.
document.head.appendChild(style);

See Importing Style Sheets for more information.

Once you’ve imported the style sheet, you can use the custom theme variant on any plain HTML element, for example a <span>.

See Theme Variants for information how apply custom theme variants using Java, JavaScript, and HTML.

Colors

<span theme="badge">Normal</span>
<span theme="badge success">Success</span>
<span theme="badge error">Error</span>
<span theme="badge contrast">Contrast</span>

<span theme="badge">1</span>
<span theme="badge success">2</span>
<span theme="badge error">12</span>
<span theme="badge contrast">99+</span>

Primary

<span theme="badge primary">Normal</span>
<span theme="badge success primary">Success</span>
<span theme="badge error primary">Error</span>
<span theme="badge contrast primary">Contrast</span>

<span theme="badge primary">1</span>
<span theme="badge success primary">2</span>
<span theme="badge error primary">12</span>
<span theme="badge contrast primary">99+</span>

Small

<span theme="badge small">Normal</span>
<span theme="badge success small">Success</span>
<span theme="badge error small">Error</span>
<span theme="badge contrast small">Contrast</span>

<span theme="badge small">1</span>
<span theme="badge success small">2</span>
<span theme="badge error small">12</span>
<span theme="badge contrast small">99+</span>

<br>

<span theme="badge small primary">Normal</span>
<span theme="badge success small primary">Success</span>
<span theme="badge error small primary">Error</span>
<span theme="badge contrast small primary">Contrast</span>

<span theme="badge small primary">1</span>
<span theme="badge success small primary">2</span>
<span theme="badge error small primary">12</span>
<span theme="badge contrast small primary">99+</span>

Pill

<span theme="badge pill">Normal</span>
<span theme="badge success pill">Success</span>
<span theme="badge error pill">Error</span>
<span theme="badge contrast pill">Contrast</span>

<span theme="badge pill">1</span>
<span theme="badge success pill">2</span>
<span theme="badge error pill">12</span>
<span theme="badge contrast pill">99+</span>

<br>

<span theme="badge primary pill">Normal</span>
<span theme="badge success primary pill">Success</span>
<span theme="badge error primary pill">Error</span>
<span theme="badge contrast primary pill">Contrast</span>

<span theme="badge primary pill">1</span>
<span theme="badge success primary pill">2</span>
<span theme="badge error primary pill">12</span>
<span theme="badge contrast primary pill">99+</span>

<h6>Small</h6>

<span theme="badge small pill">Normal</span>
<span theme="badge success small pill">Success</span>
<span theme="badge error small pill">Error</span>
<span theme="badge contrast small pill">Contrast</span>

<span theme="badge small pill">1</span>
<span theme="badge success small pill">2</span>
<span theme="badge error small pill">12</span>
<span theme="badge contrast small pill">99+</span>

<br>

<span theme="badge small primary pill">Normal</span>
<span theme="badge success small primary pill">Success</span>
<span theme="badge error small primary pill">Error</span>
<span theme="badge contrast small primary pill">Contrast</span>

<span theme="badge small primary pill">1</span>
<span theme="badge success small primary pill">2</span>
<span theme="badge error small primary pill">12</span>
<span theme="badge contrast small primary pill">99+</span>

Icon

<h5>Icon and text</h5>

<span theme="badge">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>
<br>
<span theme="badge primary">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success primary">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error primary">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast primary">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>

<br>

<span theme="badge pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>
<br>
<span theme="badge primary pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success primary pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error primary pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast primary pill">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>

<h6>Small</h6>

<span theme="badge small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>
<br>
<span theme="badge primary small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success primary small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error primary small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast primary small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>

<br>

<span theme="badge pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>
<br>
<span theme="badge primary pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Normal</span>
</span>
<span theme="badge success primary pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Success</span>
</span>
<span theme="badge error primary pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Error</span>
</span>
<span theme="badge contrast primary pill small">
  <iron-icon icon="lumo:checkmark"></iron-icon>
  <span>Contrast</span>
</span>

<h5>Icon only</h5>

<iron-icon icon="lumo:checkmark" theme="badge"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge primary"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success primary"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error primary"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast primary"></iron-icon>
<br>
<iron-icon icon="lumo:checkmark" theme="badge pill"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success pill"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error pill"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast pill"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge primary pill"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success primary pill"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error primary pill"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast primary pill"></iron-icon>

<h6>Small</h6>

<iron-icon icon="lumo:checkmark" theme="badge small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge primary small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success primary small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error primary small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast primary small"></iron-icon>
<br>
<iron-icon icon="lumo:checkmark" theme="badge pill small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success pill small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error pill small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast pill small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge primary pill small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge success primary pill small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge error primary pill small"></iron-icon>
<iron-icon icon="lumo:checkmark" theme="badge contrast primary pill small"></iron-icon>

Empty

<span theme="badge"></span>
<span theme="badge success"></span>
<span theme="badge error"></span>
<span theme="badge contrast"></span>
<br>
<span theme="badge small"></span>
<span theme="badge success small"></span>
<span theme="badge error small"></span>
<span theme="badge contrast small"></span>
Visit the <a href="https://vaadin.com" theme="badge">Vaadin</a> website!

4ED0BB21-4CFC-4EA2-BE5F-34EB113AC51C