badges.mdx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ---
  2. title: Badges
  3. summary: Badges are small count and labeling components, which are used to add extra information to an interface element. You can use them to draw users' attention to a new element, notify about unread messages or provide any kind of additional info.
  4. description: Add extra information with badges.
  5. bootstrapLink: components/badge/
  6. ---
  7. ## Default markup
  8. The default badges are square and come in the basic set of colors.
  9. ```html example centered separated
  10. <span class="badge bg-blue-lt">Blue</span>
  11. <span class="badge bg-azure-lt">Azure</span>
  12. <span class="badge bg-indigo-lt">Indigo</span>
  13. <span class="badge bg-purple-lt">Purple</span>
  14. <span class="badge bg-pink-lt">Pink</span>
  15. <span class="badge bg-red-lt">Red</span>
  16. <span class="badge bg-orange-lt">Orange</span>
  17. <span class="badge bg-yellow-lt">Yellow</span>
  18. <span class="badge bg-lime-lt">Lime</span>
  19. <span class="badge bg-green-lt">Green</span>
  20. <span class="badge bg-teal-lt">Teal</span>
  21. <span class="badge bg-cyan-lt">Cyan</span>
  22. ```
  23. ## Headings
  24. ```html example columns={1} height="20rem" centered
  25. <h1>Example heading <span class="badge">New</span>
  26. </h1>
  27. <h2>Example heading <span class="badge">New</span>
  28. </h2>
  29. <h3>Example heading <span class="badge">New</span>
  30. </h3>
  31. <h4>Example heading <span class="badge">New</span>
  32. </h4>
  33. <h5>Example heading <span class="badge">New</span>
  34. </h5>
  35. <h6>Example heading <span class="badge">New</span>
  36. </h6>
  37. ```
  38. ## Outline badges
  39. ```html example centered separated
  40. <span class="badge badge-outline text-blue">blue</span>
  41. <span class="badge badge-outline text-azure">azure</span>
  42. <span class="badge badge-outline text-indigo">indigo</span>
  43. <span class="badge badge-outline text-purple">purple</span>
  44. <span class="badge badge-outline text-pink">pink</span>
  45. <span class="badge badge-outline text-red">red</span>
  46. <span class="badge badge-outline text-orange">orange</span>
  47. <span class="badge badge-outline text-yellow">yellow</span>
  48. <span class="badge badge-outline text-lime">lime</span>
  49. <span class="badge badge-outline text-green">green</span>
  50. <span class="badge badge-outline text-teal">teal</span>
  51. <span class="badge badge-outline text-cyan">cyan</span>
  52. ```
  53. ## Pill badges
  54. Use the `.badge-pill` class if you want to create a badge with rounded corners. Its width will adjust to the label text.
  55. ```html example centered separated
  56. <span class="badge badge-pill bg-blue-lt">1</span>
  57. <span class="badge badge-pill bg-azure-lt">2</span>
  58. <span class="badge badge-pill bg-indigo-lt">3</span>
  59. <span class="badge badge-pill bg-purple-lt">4</span>
  60. <span class="badge badge-pill bg-pink-lt">5</span>
  61. <span class="badge badge-pill bg-red-lt">6</span>
  62. <span class="badge badge-pill bg-orange-lt">7</span>
  63. <span class="badge badge-pill bg-yellow-lt">8</span>
  64. <span class="badge badge-pill bg-lime-lt">9</span>
  65. <span class="badge badge-pill bg-green-lt">10</span>
  66. <span class="badge badge-pill bg-teal-lt">11</span>
  67. <span class="badge badge-pill bg-cyan-lt">12</span>
  68. ```
  69. ## Links
  70. Place the badge within an `<a>` element if you want it to perform the function of a link and make it clickable.
  71. ```html example centered separated
  72. <a href="#" class="badge bg-blue-lt">Blue</a>
  73. <a href="#" class="badge bg-azure-lt">Azure</a>
  74. <a href="#" class="badge bg-indigo-lt">Indigo</a>
  75. <a href="#" class="badge bg-purple-lt">Purple</a>
  76. <a href="#" class="badge bg-pink-lt">Pink</a>
  77. <a href="#" class="badge bg-red-lt">Red</a>
  78. <a href="#" class="badge bg-orange-lt">Orange</a>
  79. <a href="#" class="badge bg-yellow-lt">Yellow</a>
  80. <a href="#" class="badge bg-lime-lt">Lime</a>
  81. <a href="#" class="badge bg-green-lt">Green</a>
  82. <a href="#" class="badge bg-teal-lt">Teal</a>
  83. <a href="#" class="badge bg-cyan-lt">Cyan</a>
  84. ```
  85. ## Button with badge
  86. Badges can be used as part of links or buttons to provide a counter.
  87. ```
  88. <button type="button" class="btn">
  89. Notifications <span class="badge bg-red-lt ms-2">4</span>
  90. </button>
  91. ```
  92. The results can be seen in the example below.
  93. ```html example centered separated
  94. <button type="button" class="btn">Notifications <span class="badge bg-red-lt ms-2">4</span>
  95. </button>
  96. <button type="button" class="btn">Notifications <span class="badge bg-green-lt ms-2">4</span>
  97. </button>
  98. ```