Badge is a small status indicator for another element.
import { BadgeModule } from 'primeng/badge';
Content of the badge is specified using the value property.
<p-badge [value]="2" />
Content of the badge is specified using the value property.
<i class="pi pi-bell text-3xl" pBadge value="2"></i>
Severity defines the color of the badge, possible values are success, info, warning and danger
<p-badge [value]="2" severity="success" />
Badge sizes are adjusted with the badgeSize property that accepts large and xlarge as the possible alternatives to the default size. Currently sizes only apply to component mode.
<p-badge value="4" badgeSize="large" severity="warning" />
A Badge can be positioned at the top right corner of an element by adding p-overlay-badge style class to the element and embedding the badge inside.
<i class="pi pi-bell mr-4 p-text-secondary" pBadge style="font-size: 2rem" value="2"></i>
Buttons have built-in support for badges to display a badge inline.
<p-button label="Emails" badge="8" />
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-badge | Badge element |
p-overlay-badge | Wrapper of a badge and its target. |
p-badge-dot | Badge element with no value. |
p-badge-success | Badge element with success severity. |
p-badge-info | Badge element with info severity. |
p-badge-warning | Badge element with warning severity. |
p-badge-danger | Badge element with danger severity. |
p-badge-lg | Large badge element |
p-badge-xl | Extra large badge element |
Badge does not include any roles and attributes by default, any attribute is passed to the root element so aria roles and attributes can be added if required. If the badges are dynamic, aria-live may be utilized as well. In case badges need to be tabbable, tabIndex can be added to implement custom key handlers.
Component does not include any interactive elements.
API defines helper props, events and others for the PrimeNG Badge module.
Badge is a small status indicator for another element.
Defines the input properties of the component.
Badge Directive is directive usage of badge component.
Defines the input properties of the component.