DOCUMENTATION

Badges

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

Examples

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.

Heading

Example heading New

Example heading New

Example heading New

Example heading New

Example heading New

Example heading New


<p class="text-3xl font-medium leading-tight md:text-4xl">Example heading 
<span class="inline-block whitespace-nowrap px-2 leading-none md:text-3xl text-2xl font-bold text-white bg-blue-500 rounded">New</span>
</p>
<p class="text-2xl font-medium leading-tight md:text-3xl">Example heading 
<span class="inline-block whitespace-nowrap px-2 leading-none md:text-2xl text-xl font-bold text-white bg-gray-600 rounded">New</span>
</p>
<p class="text-2xl font-medium leading-tight">Example heading 
<span class="inline-block whitespace-nowrap px-2 leading-none text-xl pb-0.5 font-bold text-white bg-green-500 rounded">New</span>
</p>
<p class="text-xl font-medium leading-tight">Example heading 
<span class="inline-block whitespace-nowrap px-2 leading-none text-lg pb-0.5 font-bold text-white bg-red-600 rounded">New</span>
</p>
<p class="text-lg font-medium leading-tight">Example heading 
<span class="inline-block whitespace-nowrap px-2 leading-none  pb-0.5 font-bold text-white bg-orange-500 rounded">New</span>
</p>
<p class=" font-medium leading-tight">Example heading 
<span class="inline-block whitespace-nowrap px-2 leading-none text-sm pb-0.5 font-bold text-white bg-cyan-500 rounded">New</span>
</p>    
        

Buttons

<button type="button" class="btn btn-primary">
Notifications<span class="badge bg-secondary">4</span>
</button>

Positioned

Use utilities to modify a .badge and position it in the corner of a link or button.

<button type="button" class="btn btn-primary position-relative">
Inbox
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
    99 <span class="visually-hidden">unread messages</span>
</span>
</button>

You can also replace the .badge class with a few more utilities without a count for a more generic indicator.

<button type="button" class="btn btn-primary position-relative">
Profile
<span class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle">
<span class="visually-hidden">New alerts</span>
</span>
</button>

background colors

Use our background utility classes to quickly change the appearance of a badge. Please note that when using Tailwind’s default .bg-blue-500, you’ll likely need a text color utility like .text-blue-500 for proper styling. This is because background utilities do not set anything but background-color.

Primary Secondary Success Danger Warning Info Light Dark

<div class="mt-4">
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-white bg-blue-500 rounded-full">Primary</span>
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-white bg-gray-600 rounded-full">Secondary</span>
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-white bg-green-500 rounded-full">Success</span>
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-white bg-red-500 rounded-full">Danger</span>
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-white bg-orange-500 rounded-full">Warning</span>
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-white bg-cyan-500 rounded-full">Info</span>
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-black bg-gray-300 rounded-full">Light</span>
<span class="inline-block whitespace-nowrap px-2 py-0.5 text-xs text-center font-bold leading-none text-white bg-black rounded-full">Dark</span>
</div> 
            

Pill badges

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

Primary Secondary Success Danger Warning Info Light Dark
                  
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none text-blue-500  bg-blue-100  rounded-full">Primary</span>
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none text-gray-600  bg-gray-300  rounded-full">Secondary</span>
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none text-green-500  bg-green-100  rounded-full">Success</span>
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none text-red-500  bg-red-100  rounded-full">Danger</span>
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none text-orange-500  bg-orange-100  rounded-full ">Warning</span>
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none  rounded-full text-teal-500 bg-teal-100">Info</span>
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none text-gray-800  bg-gray-100  rounded-full">Light</span>
  <span class="inline-block whitespace-nowrap px-2 py-1 mb-2 text-xs text-center font-bold leading-none text-slate-900  bg-slate-300  rounded-full">Dark</span>
  

Pill custom badges

Use the .rounded-pill & iq-custom-badge utility class to make badges more rounded with a larger border-radius and button at end on pills.

Primary Secondary Success Warning Danger

<!-- Normal icon badge -->
<span class="inline-block whitespace-nowrap px-4 py-1 mb-2 mr-3 text-base text-center leading-none text-blue-500  bg-blue-100  rounded-full">Primary
    <button>
      <svg width="15" height="15" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
        stroke="currentColor" class="bg-blue-500 stroke-white rounded-full -mr-10">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12">
        </path>
      </svg>
    </button>
  </span>

    
Primary Secondary Success Warning Danger

<!-- Normal icon badge -->
<span class="inline-block whitespace-nowrap px-4 py-1 mb-2 mr-3 text-base text-center leading-none text-blue-500  bg-blue-100  rounded-md">Primary
    <button>
      <svg width="15" height="15" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
        stroke="currentColor" class="bg-blue-500 stroke-white rounded -mr-10">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12">
        </path>
      </svg>
    </button>
</span>

    

Updated on February 28, 2022
Was this page helpful?