Badges

Vue Bootstrap 5 Badges component

Documentation and examples for Vue badges, our small count and labeling component.

Note: Read the API tab to find all available options and advanced customization


Basic example

Example heading New


          <template>
            Example heading <MDBBadge color="primary">New</MDBBadge>
          </template>
        

          <script>
            import { MDBBadge } from "mdb-vue-ui-kit"; export default { components: { MDBBadge } };
          </script>
        

Sizes

Badges scale to match the size of the immediate parent element by using relative font sizing and em units. As of v5, badges no longer have focus or hover styles for links.

Example heading New

Example heading New

Example heading New

Example heading New

Example heading New
Example heading New

          <template>
            <div>
              <h1>Example heading <MDBBadge color="primary">New</MDBBadge></h1>
              <h2>Example heading <MDBBadge color="primary">New</MDBBadge></h2>
              <h3>Example heading <MDBBadge color="primary">New</MDBBadge></h3>
              <h4>Example heading <MDBBadge color="primary">New</MDBBadge></h4>
              <h5>Example heading <MDBBadge color="primary">New</MDBBadge></h5>
              <h6>Example heading <MDBBadge color="primary">New</MDBBadge></h6>
            </div>
          </template>
        

          <script>
            import { MDBBadge } from "mdb-vue-ui-kit"; export default { components: { MDBBadge } };
          </script>
        

Button

Badges can be used as part of links or buttons to provide a counter.


          <template>
            <MDBBtn color="primary">
              Notifications<MDBBadge color="danger" class="ms-2">8</MDBBadge>
            </MDBBtn>
          </template>
        

          <script>
            import { MDBBadge, MDBBtn } from "mdb-vue-ui-kit"; export default { components: {
            MDBBadge, MDBBtn } };
          </script>
        

Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.

Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.


          <template>
            <MDBBtn color="primary">
              Profile<MDBBadge color="danger" class="ms-2">9</MDBBadge>
              <span class="visually-hidden">unread messages</span>
            </MDBBtn>
          </template>
        

          <script>
            import { MDBBadge, MDBBtn } from "mdb-vue-ui-kit"; export default { components: {
            MDBBadge, MDBBtn } };
          </script>
        

Colors

Use our background utility classes to quickly change the appearance of a badge. Please note that when using Bootstrap’s default color="light" property, you’ll likely need a text color utility like .text-dark for proper styling. This is because background properties do not set anything but background-color.

Primary Secondary Success Danger Warning Info Light Dark

          <template>
            <MDBBadge color="primary">Primary</MDBBadge>
            <MDBBadge color="secondary">Secondary</MDBBadge>
            <MDBBadge color="success">Success</MDBBadge>
            <MDBBadge color="danger">Danger</MDBBadge>
            <MDBBadge color="warning" class="text-dark">Warning</MDBBadge>
            <MDBBadge color="info">Info</MDBBadge>
            <MDBBadge color="light" class="text-dark">Light</MDBBadge>
            <MDBBadge color="dark">Dark</MDBBadge>
          </template>
        

          <script>
            import { MDBBadge } from "mdb-vue-ui-kit"; export default { components: { MDBBadge } };
          </script>
        

Conveying meaning to assistive technologies:
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.


Pills

Use the pill property to make badges more rounded with a larger border-radius.

Primary Secondary Success Danger Warning Info Light Dark

          <template>
            <MDBBadge color="primary" pill>Primary</MDBBadge>
            <MDBBadge color="secondary" pill>Secondary</MDBBadge>
            <MDBBadge color="success" pill>Success</MDBBadge>
            <MDBBadge color="danger" pill>Danger</MDBBadge>
            <MDBBadge color="warning" class="text-dark" pill>Warning</MDBBadge>
            <MDBBadge color="info" pill>Info</MDBBadge>
            <MDBBadge color="light" class="text-dark" pill>Light</MDBBadge>
            <MDBBadge color="dark" pill>Dark</MDBBadge>
          </template>
        

          <script>
            import { MDBBadge } from "mdb-vue-ui-kit"; export default { components: { MDBBadge } };
          </script>
        

Icon notifications

You can use our icons and notification property to create a facebook-like notification.



1

999+

          <template>
            <a href="">
              <MDBIcon icon="envelope" size="lg"></MDBIcon>
              <MDBBadge color="danger" dot></MDBBadge>
            </a>

            <br />
            <br />

            <a href="">
              <MDBIcon icon="envelope" size="lg"></MDBIcon>
              <MDBBadge color="danger" pill notification>1</MDBBadge>
            </a>

            <br />
            <br />

            <a href="">
              <MDBIcon icon="envelope" size="lg"></MDBIcon>
              <MDBBadge color="danger" pill notification>999+</MDBBadge>
            </a>
          </template>
        

          <script>
          import { MDBBadge, MDBIcon } from "mdb-vue-ui-kit"; export default { components: {
          MDBBadge, MDBIcon } };
          </script>
        

Badges - API


Import


        <script>
          import {
            MDBBadge
          } from 'mdb-vue-ui-kit';
        </script>
      

Properties

Property Type Default Description
color String "" Changes badge color
pill Boolean false Changes badge to rounded-pill
dot Boolean false Changes badge to dot style
notification Boolean false Changes badge to notification style
tag String "span" Changes badge tag