Badges

Create handsome looking badges & tags easily with these classes.

Usage

The mesh badge should be prefixed with the .badge class which will give you access to all of the classes outlined below.
They are designed to be used with the <span> element.
Note: You can have any combination of the classes listed below.

Default Light Dark Black
<span class="badge">Default</span>
<span class="badge badge-light">Light</span>
<span class="badge badge-dark">Dark</span>
<span class="badge badge-black">Black</span>Copy iconSuccess icon

Colored

You can add color classes to brighten up the badges by prefixing it with .badge-{color} class which will give you access to all of the classes outlined below.

Primary Success Info Warning Danger Link
<span class="badge badge-primary">Primary</span>
<span class="badge badge-success">Success</span>
<span class="badge badge-info">Info</span>
<span class="badge badge-warning">Warning</span>
<span class="badge badge-danger">Danger</span>Copy iconSuccess icon

Rounded

You can make badges rounded with the .badge-rounded class.

Primary Success Info Warning Danger Link
<span class="badge badge-rounded badge-primary">Primary</span>
<span class="badge badge-rounded badge-success">Success</span>
<span class="badge badge-rounded badge-info">Info</span>
<span class="badge badge-rounded badge-warning">Warning</span>
<span class="badge badge-rounded badge-danger">Danger</span>Copy iconSuccess icon

Notifications

Mesh badges can be added to buttons as notifications without additional markup.

<button class="btn btn-primary d-flex align-items-center">
Notifications
<span class="badge badge-light">10</badge>
</button>Copy iconSuccess icon

Close

To add a closeable button to the badge, simply add badge-close class to enable a hover effect. Then add an icon of your choice, we have stuck with font awesome and add the badge-delete class to the icon.

Primary Success Info Warning Danger Link
<span class="badge badge-close badge-primary">
    Primary
    <i class="badge-delete fas fa-times"></i>
</span>
<span class="badge badge-close badge-success">
    Success
    <i class="badge-delete fas fa-times"></i>
</span>
<span class="badge badge-close badge-info">
    Info
    <i class="badge-delete fas fa-times"></i>
</span>
<span class="badge badge-close badge-warning">
    Warning
    <i class="badge-delete fas fa-times"></i>
</span>
<span class="badge badge-close badge-danger">
    Danger
    <i class="badge-delete fas fa-times"></i>
</span>
<span class="badge badge-close badge-link">
    Link
    <i class="badge-delete fas fa-times"></i>
</span>Copy iconSuccess icon

JS close

To add close functionality to the closeable badges, use the script below. Go ahead and close the tags!

Primary Success Info Warning Danger Link
document.addEventListener('DOMContentLoaded', () => {
    (document.querySelectorAll('.badge-close .badge-delete') || []).forEach(close => {
        close.addEventListener('click', () => {
            close.parentNode.remove();
        });
    });
});Copy iconSuccess icon

Variables

Choose from different badge options and enable/disable classes you require. Customise the font style & padding of the badges too.

Variable Value Description
$badge-enable-colored: true;
Boolean Enables/disables coloured badges.
$badge-enable-rounded: true;
Boolean Enables/disables rounded badges.
$badge-enable-deletable: true;
Boolean Enables/disables deleteable badges (x with hover).
$badge-padding: 3px 12px;
Pixel/em/rem Padding amount for badges in pixels, em's or rem's.
$badge-font-size: 10px;
Pixel/em/rem Font size for badges in pixels, em's or rem's.
$badge-font-weight: 400;
CSS font weight Font weight of badges with properties above.