Examples
Badges scale to match the size of the immediate parent element by using relative font sizing and em
units.
Headings
Example heading New
Example heading New
Example heading New
Example heading New
Example heading New
Example heading New
<template>
<h1>
Example heading
<Badge color="secondary">
New
</Badge>
</h1>
<h2>
Example heading
<Badge color="secondary">
New
</Badge>
</h2>
<h3>
Example heading
<Badge color="secondary">
New
</Badge>
</h3>
<h4>
Example heading
<Badge color="secondary">
New
</Badge>
</h4>
<h5>
Example heading
<Badge color="secondary">
New
</Badge>
</h5>
<h6>
Example heading
<Badge color="secondary">
New
</Badge>
</h6>
</template>
Buttons
Badges can be used as part of links or buttons to provide a counter.
<template>
<b-button color="primary">
Notifications
<Badge color="secondary">
4
</Badge>
</b-button>
</template>
Positioned
Use utilities to modify a Badge
and position it in the corner of a link or button.
<template>
<b-button
color="primary"
position="relative"
>
Inbox
<Badge
position="absolute"
top="0"
start="100"
translate="middle"
rounded="pill"
color="danger"
label="unread messages"
>
99+
</Badge>
</b-button>
</template>
You can also modify the Badge
component with a few more utilities without a count for a more generic indicator.
<template>
<b-button
color="primary"
position="relative"
>
Profile
<Badge
position="absolute"
top="0"
start="100"
translate="middle"
color="danger"
label="New alerts"
border-color="light"
rounded="circle"
padding="2"
/>
</b-button>
</template>
Background colors
Use our background utility classes to quickly change the appearance of a badge.
Please note that when using Bootstrap's default background-color="light"
, you'll likely need a text color utility like text-color="dark"
for proper styling.
This is because background utilities do not set anything but background-color
.
<template>
<Badge color="primary">
Primary
</Badge>
<Badge color="secondary">
Secondary
</Badge>
<Badge color="success">
Success
</Badge>
<Badge color="danger">
Danger
</Badge>
<Badge color="warning">
Warning
</Badge>
<Badge color="info">
Info
</Badge>
<Badge color="light">
Light
</Badge>
<Badge color="dark">
Dark
</Badge>
</template>
Pill badges
Use the rounded="pill"
utility, class to make badges more rounded with a larger border-radius
.
<template>
<Badge
color="primary"
rounded="pill"
>
Primary
</Badge>
<Badge
color="secondary"
rounded="pill"
>
Secondary
</Badge>
<Badge
color="success"
rounded="pill"
>
Success
</Badge>
<Badge
color="danger"
rounded="pill"
>
Danger
</Badge>
<Badge
color="warning"
rounded="pill"
>
Warning
</Badge>
<Badge
color="info"
rounded="pill"
>
Info
</Badge>
<Badge
color="light"
rounded="pill"
>
Light
</Badge>
<Badge
color="dark"
rounded="pill"
>
Dark
</Badge>
</template>