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

Bootstrap4 Badges

Bootstrap4 Badges

Badges are mainly used to highlight new or unread items. To use a badge, simply add the .badge class along with a contextual color class (such as .badge-secondary) to the element. Badges can also scale with the size of the parent element:

Example

<

h1

Test Heading

<span class=">

badge badge-secondary

"

New

span

h1

<

h2

Test Heading

<span class=">

badge badge-secondary

"

New

span

h2

<

h3

Test Heading

<span class=">

badge badge-secondary

"

New

span

h3

<

h4

Test Heading

<span class=">

badge badge-secondary

"

New

span

h4

<

h5

Test Heading

<span class=">

badge badge-secondary

"

New

span

h5

<

h6

Test Heading

<span class=">

badge badge-secondary

"

New

span

h6

Try it »


Badges of Various Colors

The following lists badges of all color types:

Example

<span class=">

badge badge-primary

"

Primary

span

<span class=">

badge badge-secondary

"

Secondary

span

<span class=">

badge badge-success

"

Success

span

<span class=">

badge badge-danger

"

Danger

span

<span class=">

badge badge-warning

"

Warning

span

<span class=">

badge badge-info

"

Information

span

<span class=">

badge badge-light

"

Light

span

<span class=">

badge badge-dark

"

Dark

span

Try it »


Pill-shaped Badges

Use the .badge-pill class to create pill-shaped badges:

Example

<span class=">

badge badge-pill badge-default

"

Default

span

<span class=">

badge badge-pill badge-primary

"

Primary

span

<span class=">

badge badge-pill badge-success

"

Success

span

<span class=">

badge badge-pill badge-info

"

Information

span

<span class=">

badge badge-pill badge-warning

"

Warning

span

<span class=">

badge badge-pill badge-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 badge-light

"

4

span

button

Try it »