How to use badges in Bootstrap 4
Badges are used to provide additional information about an item. We use the badge class to create rectangle badges. We can utilize it in combination with the contextual class. Badges should be specified within the span tag.
Note: Badges are resized to their parent element's size.
This concept is shown in the following illustration:
Code
Explanation
Line 5–6: Link Bootstrap 4 with our layout.
Line 10–16: Create four buttons to display the numbers for notifications, updates, messages, and pings using the
badgeclass.Contextual classes such as
badge-success,btn-warning, and others are used to change the badge colors.The
m-2tag is used to give a margin with an intensity of two.The
btn-lgandbtn-smtags are used to make the large and small buttons respectively.
Free Resources