Docs
πŸ—οΈ ⏐ Components
Elements
Badge

Badge

The Badge component serves as a small count and labeling tool that overlays its content on another element, typically used for displaying notifications, status, or additional info like new messages or alerts. It's designed to draw attention to specific elements by showing relevant numbers or indicators.

Quick Start

To start using the Badge component, import it from the reablocks library and provide the content prop.

Examples

Basic Usage (Color Variations)

The Badge component can be styled with various colors to indicate different statuses or priorities. Here's how to display badges with default, primary, secondary, and error color schemes:

Advanced Usage (Position Variations)

The position of a Badge relative to its child component can be customized to appear in various locations like top-start, top-end, bottom-start, and bottom-end:

Theme Customization

The Badge component comes with a default theme that can be customized according to your application's design system:

  • root{}(6 keys)
      Show all

Learn more about how to customize in the Theme documentation.

API

Customize the Badge component through the following properties:

PropDescriptionDefault
contentThe content of the badge.
string | Element
colorThe color of the badge.
string
default
disableMarginsWhether to disable the margins.
boolean
hiddenWhether the badge is hidden or not.
boolean
placementThe placement of the badge.
BadgePlacement
top-end
themeTheme for the Budge.
BadgeTheme
refReference to the HTML span element.
LegacyRef<HTMLSpanElement>

Design and Usability Tips

  • Visibility at a Glance: Design badges to be easily scannable, using minimal text or numbers and high-contrast colors to stand out from their background.
  • Avoid Overuse: Use badges sparingly within the interface to prevent dilution of their significance; too many badges can overwhelm users and diminish their attention-grabbing effect.