Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap5 Badges

Bootstrap5 Badges

Badges are mainly used to highlight new or unread items. To use a badge, you only need to add the .badge class plus a meaningful color class (such as .bg-secondary) to the element. Badges can also scale with the size of the parent element:

Example

<

h1

Test Heading

<span class=">

badge bg-secondary

"

New

span

h1

<

h2

Test Heading

<span class=">

badge bg-secondary

"

New

span

h2

<

h3

Test Heading

<span class=">

badge bg-secondary

"

New

span

h3

<

h4

Test Heading

<span class=">

badge bg-secondary

"

New

span

h4

<

h5

Test Heading

<span class=">

badge bg-secondary

"

New

span

h5

<

h6

Test Heading

<span class=">

badge bg-secondary

"

New

span

h6

Try it »


Badges of Various Colors

The following lists badges of all color types:

Example

<span class=">

badge bg-primary

"

Primary

span

<span class=">

badge bg-secondary

"

Secondary

span

<span class=">

badge bg-success

"

Success

span

<span class=">

badge bg-danger

"

Danger

span

<span class=">

badge bg-warning

"

Warning

span

<span class=">

badge bg-info

"

Information

span

<span class=">

badge bg-light

"

Light

span

<span class=">

badge bg-dark

"

Dark

span

Try it »


Pill-shaped Badges

Use the .rounded-pill class to set a pill-shaped badge:

Example

<span class=">

badge rounded-pill bg-primary

"

Primary

span

<span class=">

badge rounded-pill bg-success

"

Success

span

<span class=">

badge rounded-pill bg-info

"

Information

span

<span class=">

badge rounded-pill bg-warning

"

Warning

span

<span class=">

badge rounded-pill bg-danger

"

Danger

span

Try it »


Embedding Badges in Elements

The following example embeds a badge inside a button:

Example

<button type="button" class=">

btn btn-primary

"

Messages

<span class=">

badge bg-light

"

4

span

button

Try it »