Robert's Resume

Badges

Code

.badge

.rounded-pill

.position-relative

.position-absolute

.translate-middle

.rounded-circle

Top

Definitions

Badge
▪ Adds a button-like box to text.
Pill
▪ Changes border-radius to make element look like a pill.
Relative Position
▪ Positioned relative to its normal position. Other content will not be adjusted to fit into any gap left.
Absolute Position
▪ Positioned relative to the nearest ancestor. Can overlap other elements.
Translate Middle
▪ Applies translateX (-50%) and translateY(-50%) allowing you to absolute center an element.
Rounded Circle
▪ Creates a circle.
Top

Key Points

  • Badges scale to the size of the immediate parent.
  • In Bootstrap 5, badges no longer have focus or hover styles for links.
  • Badges my be confusing for screen readers. Consider using additional context with a visually hidden piece of additional text.
  • Top

Basic Badges

Example heading Special

Example heading Special

Example heading Special

Example heading Special

Example heading Special
Example heading Special

Add .badge to an element (usually a <span>) to create a badge.

Top

Badges With Colors

Primary

Secondary

Success

Danger

Warning

Info

Light

Dark

Add text-bg-* to .badge, where * indicates a contextual class, to create a badge with color.

NOTE: You can use .bg-* instead of .text-bg-*, but you will not get the corrected text color.

Top

Pills Shaped Badges

Primary

Secondary

Success

Danger

Warning

Info

Light

Dark

Add .rounded-pill to .badge to create a pill badge.

Top

Badges Inside Elements

Add a badge inside another element, such as a <button>.

Top