Tag

Tag component is used to categorize content.


import { TagModule } from 'primeng/tag';

Label of the tag is defined with the value property.

New

<p-tag value="New" />

Severity defines the color of the tag, possible values are success, info, warning and danger in addition to the default theme color.

PrimarySuccessSecondaryInfoWarningDangerContrast

<p-tag severity="success" value="Success"/>

Enabling rounded, displays a tag as a pill.

PrimarySuccessInfoSecondaryWarningDangerContrast

<p-tag value="Primary" [rounded]="true" />

A font icon next to the value can be displayed with the icon property.

PrimarySuccessInfoWarningDanger

<p-tag icon="pi pi-user" value="Primary" />

Children of the component are passed as the content for templating.

CountryItaly

<p-tag [style]="{ background: 'linear-gradient(to right, var(--surface-900), var(--surface-700)' }">
    <div class="flex align-items-center gap-2 px-1">
        <img 
            alt="Country" 
            src="https://primefaces.org/cdn/primeng/images/demo/flag/flag_placeholder.png" 
            class="flag flag-it" 
            style="width: '18px'" />
        <span class="text-base">
            Italy
        </span>
    </div>
</p-tag>

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-tagTag element
p-tag-roundedRounded element
p-tag-iconIcon of the tag
p-tag-valueValue of the tag

Screen Reader

Tag 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 tags 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.

Keyboard Support

Component does not include any interactive elements.