badges.mdx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 vertical centered separated scrollable height="15rem"
  10. <span class="badge bg-blue">Blue</span>
  11. <span class="badge bg-azure">Azure</span>
  12. <span class="badge bg-indigo">Indigo</span>
  13. <span class="badge bg-purple">Purple</span>
  14. <span class="badge bg-pink">Pink</span>
  15. <span class="badge bg-red">Red</span>
  16. <span class="badge bg-orange">Orange</span>
  17. <span class="badge bg-yellow">Yellow</span>
  18. <span class="badge bg-lime">Lime</span>
  19. <span class="badge bg-green">Green</span>
  20. <span class="badge bg-teal">Teal</span>
  21. <span class="badge bg-cyan">Cyan</span>
  22. ```
  23. ## Headings
  24. ```html example height="240px"
  25. <h1>Example heading <span class="badge bg-secondary">New</span>
  26. </h1>
  27. <h2>Example heading <span class="badge bg-secondary">New</span>
  28. </h2>
  29. <h3>Example heading <span class="badge bg-secondary">New</span>
  30. </h3>
  31. <h4>Example heading <span class="badge bg-secondary">New</span>
  32. </h4>
  33. <h5>Example heading <span class="badge bg-secondary">New</span>
  34. </h5>
  35. <h6>Example heading <span class="badge bg-secondary">New</span>
  36. </h6>
  37. ```
  38. ## Outline badges
  39. ```html example vertical centered separated scrollable height="15rem"
  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 height="7rem"
  56. <span class="badge badge-pill bg-blue">1</span>
  57. <span class="badge badge-pill bg-azure">2</span>
  58. <span class="badge badge-pill bg-indigo">3</span>
  59. <span class="badge badge-pill bg-purple">4</span>
  60. <span class="badge badge-pill bg-pink">5</span>
  61. <span class="badge badge-pill bg-red">6</span>
  62. <span class="badge badge-pill bg-orange">7</span>
  63. <span class="badge badge-pill bg-yellow">8</span>
  64. <span class="badge badge-pill bg-lime">9</span>
  65. <span class="badge badge-pill bg-green">10</span>
  66. <span class="badge badge-pill bg-teal">11</span>
  67. <span class="badge badge-pill bg-cyan">12</span>
  68. ```
  69. ## Soft color badges
  70. You can create a soft colour variant of a corresponding contextual badge variation, to make it look more subtle. Click [here](/docs/ui/base/colors) to see the list of available colors and choose ones that best suit your design.
  71. ```html example vertical centered separated scrollable height="15rem"
  72. <span class="badge bg-blue-lt">Blue</span>
  73. <span class="badge bg-azure-lt">Azure</span>
  74. <span class="badge bg-indigo-lt">Indigo</span>
  75. <span class="badge bg-purple-lt">Purple</span>
  76. <span class="badge bg-pink-lt">Pink</span>
  77. <span class="badge bg-red-lt">Red</span>
  78. <span class="badge bg-orange-lt">Orange</span>
  79. <span class="badge bg-yellow-lt">Yellow</span>
  80. <span class="badge bg-lime-lt">Lime</span>
  81. <span class="badge bg-green-lt">Green</span>
  82. <span class="badge bg-teal-lt">Teal</span>
  83. <span class="badge bg-cyan-lt">Cyan</span>
  84. ```
  85. ## Links
  86. Place the badge within an `<a>` element if you want it to perform the function of a link and make it clickable.
  87. ```html example vertical centered separated scrollable height="15rem"
  88. <a href="#" class="badge bg-blue">Blue</a>
  89. <a href="#" class="badge bg-azure">Azure</a>
  90. <a href="#" class="badge bg-indigo">Indigo</a>
  91. <a href="#" class="badge bg-purple">Purple</a>
  92. <a href="#" class="badge bg-pink">Pink</a>
  93. <a href="#" class="badge bg-red">Red</a>
  94. <a href="#" class="badge bg-orange">Orange</a>
  95. <a href="#" class="badge bg-yellow">Yellow</a>
  96. <a href="#" class="badge bg-lime">Lime</a>
  97. <a href="#" class="badge bg-green">Green</a>
  98. <a href="#" class="badge bg-teal">Teal</a>
  99. <a href="#" class="badge bg-cyan">Cyan</a>
  100. ```
  101. ## Button with badge
  102. Badges can be used as part of links or buttons to provide a counter.
  103. ```html example centered separated height="7rem"
  104. <button type="button" class="btn">Notifications <span class="badge bg-red ms-2">4</span>
  105. </button>
  106. <button type="button" class="btn">Notifications <span class="badge bg-green ms-2">4</span>
  107. </button>
  108. ```
  109. ```html
  110. <button type="button" class="btn">
  111. Notifications <span class="badge bg-red ms-2">4</span>
  112. </button>
  113. <button type="button" class="btn">
  114. Notifications <span class="badge bg-green ms-2">4</span>
  115. </button>
  116. ```