Badge

A small count and labeling component used to highlight information, statuses, or notifications, providing visual indicators for important data points.

Basic Badge

The badge component can be created by calling the UI::badge() method.

New
php
Options
The Badge component can be customized using the badgeOptions() method, it accepts multiple options at the same time.
  • Badge::SOFT: Creates a badge with a softer, more subtle appearance using a light background and colored text.
  • Badge::OUTLINE: Creates a badge with an outline style.
  • Badge::ROUNDED: Creates a pill-shaped badge with fully rounded ends.
  • Badge::CIRCLE: Creates a circular badge.
  • Badge::BORDER: Creates a badge with a border.
  • Badge::LABEL: Creates a badge styled as a label.
Badge Options Examples
Here are examples of each badge option to showcase their visual effect.

Colored Badge

The bsStyle() method sets the color theme for the badge.

Success
php

Soft Badge

The Badge::SOFT option creates a more subtle badge with a lighter background.

Warning
php

Outline Badge

The Badge::OUTLINE option creates a badge with an outline style.

Error
php

Rounded Badge

The Badge::ROUNDED option creates a pill-shaped badge with fully rounded ends.

Info
php

Circle Badge

The Badge::CIRCLE option creates a circular badge, often used for notification counts.

3
php

Border Badge

The Badge::BORDER option creates a badge with a border.

Bordered
php

Label Badge

The Badge::LABEL option creates a badge styled as a label.

Label
php

Combined Options

Multiple options can be combined using the bitwise OR operator (|).

Soft Rounded
php

API

The badge component extends from HtmlElement so it has all its methods available.
API PHP

Common alternative names: Tag, Chip, Label, Pill, Counter, Indicator, Status Indicator

Types: Default Badges, Soft Badges, Outline Badges, Rounded Badges, Circle Badges, Border Badges, Label Badges


Principles

Visual Emphasis

Badges draw attention to important information by using color, contrast, and positioning to make key details stand out within the interface.

Information Density

Badges efficiently communicate status, quantity, or category information in a small, compact form, allowing users to quickly scan and understand data.

Contextual Communication

Badges use color and shape conventions to convey meaning, making information immediately recognizable without requiring additional explanation.


Anatomy

Badge Anatomy
  1. Icon
  2. Optional visual indicator that can be added to the badge

  3. Content
  4. The main text or number displayed in the badge

  5. Container
  6. The outer wrapper that holds the badge content


Usage

Use badges to highlight and draw attention to status, counts, labels, or notification indicators. They're particularly effective for displaying unread counts, status indicators, categorization tags, version numbers, and feature labels. Badges should be used sparingly to avoid overwhelming the interface, and their colors should follow a consistent system where each color has a specific meaning (e.g., red for errors, green for success).