Package org.patternfly.component.label
package org.patternfly.component.label
Provides label and label group components for displaying compact, categorized metadata.
This package contains the Label and
LabelGroup components for displaying tags, categories, or status
indicators. Labels support multiple colors, filled and outline variants, icons, close buttons, clickable
behavior, editable text, and overflow truncation. Label groups organize multiple labels together with
optional overflow handling.
Components
Label- Individual label with color, variant, icon, and close supportLabelGroup- Groups multiple labels with optional overflowLabelEditCompleteHandler- Handler for label edit completionLabelEditCancelHandler- Handler for label edit cancellation
Usage
Labels with different colors and variants:
import static org.patternfly.component.label.Label.label;
import static org.patternfly.component.label.LabelGroup.labelGroup;
import static org.patternfly.icon.IconSets.fas.infoCircle;
import static org.patternfly.style.Color.blue;
import static org.patternfly.style.Color.green;
import static org.patternfly.style.Color.red;
// Filled labels with different colors
Label blueLabel = label("Blue", blue).filled();
Label greenLabel = label("Green", green).filled().icon(infoCircle());
Label removable = label("Removable", red).filled().closable();
// Outline labels
Label outlineLabel = label("Outline", blue).outline();
// Compact and clickable labels
Label compact = label("Compact").compact().filled();
Label clickable = label("Clickable", blue).filled()
.clickable((e, l) -> console.log("Label clicked"));
// Label group
LabelGroup group = labelGroup()
.addItem(label("Label 1", blue).filled())
.addItem(label("Label 2", green).filled())
.addItem(label("Label 3", red).filled().closable());
- See Also:
-
ClassDescriptionThe label component allows users to add specific element captions for user clarity and convenience.