PatternFly

Label

The label component allows users to add specific element captions for user clarity and convenience.

Examples

Filled labels

GreyGrey icon Grey removable Grey icon removable Grey link Grey link removable Grey label with icon that overflows Grey link removable (disabled)

Blue Blue icon Blue removable Blue icon removable Blue link Blue link removable Blue label with icon that overflows Blue link removable (disabled)

Green Green icon Green removable Green icon removable Green link Green link removable Green label with icon that overflows Green link removable (disabled)

Orange Orange icon Orange removable Orange icon removable Orange link Orange link removable Orange label with icon that overflows Orange link removable (disabled)

Red Red icon Red removable Red icon removable Red link Red link removable Red label with icon that overflows Red link removable (disabled)

Purple Purple icon Purple removable Purple icon removable Purple link Purple link removable Purple label with icon that overflows Purple link removable (disabled)

Cyan Cyan icon Cyan removable Cyan icon removable Cyan link Cyan link removable Cyan label with icon that overflows Cyan link removable (disabled)

Gold Gold icon Gold removable Gold icon removable Gold link Gold link removable Gold label with icon that overflows Gold link removable (disabled)

Label that overflows its parent, but has no textMaxWidth on its own

Outlined labels

Grey Grey icon Grey removable Grey icon removable Grey link Grey link removable Grey label with icon that overflows Grey link removable (disabled)

Blue Blue icon Blue removable Blue icon removable Blue link Blue link removable Blue label with icon that overflows Blue link removable (disabled)

Green Green icon Green removable Green icon removable Green link Green link removable Green label with icon that overflows Green link removable (disabled)

Orange Orange icon Orange removable Orange icon removable Orange link Orange link removable Orange label with icon that overflows Orange link removable (disabled)

Red Red icon Red removable Red icon removable Red link Red link removable Red label with icon that overflows Red link removable (disabled)

Purple Purple icon Purple removable Purple icon removable Purple link Purple link removable Purple label with icon that overflows Purple link removable (disabled)

Cyan Cyan icon Cyan removable Cyan icon removable Cyan link Cyan link removable Cyan label with icon that overflows Cyan link removable (disabled)

Gold Gold icon Gold removable Gold icon removable Gold link Gold link removable Gold label with icon that overflows Gold link removable (disabled)

Compact labels

Grey Compact icon Compact removable Compact icon removable Compact link Compact link removable Compact label with icon that overflows Compact link removable (disabled)

Editable labels

Click or press either enter or space to begin editing a label. After editing, click outside the label or press enter again to complete the edit. To cancel an edit, press escape.

You can also customize any Label's close button aria-label as this example shows with closeBtnAriaLabel.

Basic label group

Use a label group when you have multiple labels to display at once.

  • Label 1
  • Label 2
  • Label 3

Label group with overflow

An overflow label can be added to the end of a group to save space when the number of labels exceeds some threshold. Click the overflow label to expand and collapse the group.

  • Label 1
  • Label 2
  • Label 3

Label group with categories

Use a category name to organize a set of labels

  • Label 1
  • Label 2
  • Label 3

Label group with removable categories

  • Label 1
  • Label 2
  • Label 3

Vertical label group

Labels in a group can also be stacked vertically. This example shows a verical label group with a category name and overflow.

  • Label 1
  • Label 2
  • Label 3

Editable label group

  • Static label

Editable label group with add button

The contents of a label group can be modified by removing labels or adding new ones using the add button. For additional documentation that showcases adding a new label, see label demos.

  • Label 1
  • Label 2

Props

Label

*required
NameTypeDefaultDescription
childrenReact.ReactNodeContent rendered inside the label.
classNamestring''Additional classes added to the label.
closeBtnReact.ReactNodeNode for custom close button.
closeBtnAriaLabelstringAria label for close button
closeBtnPropsanyAdditional properties for the default close button.
color'blue' | 'cyan' | 'green' | 'orange' | 'purple' | 'red' | 'grey' | 'gold''grey'Color of the label.
editablePropsBetaanyAdditional props passed to the editable label text div. Optionally passing onInput and onBlur callbacks will allow finer custom text input control.
hrefstringHref for a label that is a link. If present, the label will change to an anchor element. This should not be passed in if the onClick prop is also passed in.
iconReact.ReactNodeIcon added to the left of the label text.
isCompactbooleanfalseFlag indicating the label is compact.
isDisabledbooleanfalseFlag indicating the label is disabled. Works only on clickable labels, so either href or onClick props must be passed in.
isEditableBetabooleanfalseFlag indicating the label is editable.
isOverflowLabelbooleanFlag indicating if the label is an overflow label.
onClick(event: React.MouseEvent) => voidCallback for when the label is clicked. This should not be passed in if the href or isEditable props are also passed in.
onClose(event: React.MouseEvent) => voidClose click callback for removable labels. If present, label will have a close button.
onEditCancelBeta(event: KeyboardEvent, previousText: string) => voidCallback when an editable label cancels an edit.
onEditCompleteBeta(event: MouseEvent | KeyboardEvent, newText: string) => voidCallback when an editable label completes an edit.
render({ className, content, componentRef }: { className: string; content: React.ReactNode; componentRef: any; }) => React.ReactNodeForwards the label content and className to rendered function. Use this prop for react router support.
textMaxWidthstringThe max width of the label before it is truncated. Can be any valid CSS unit, such as '100%', '100px', or '16ch'.
tooltipPosition| TooltipPosition | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end'Position of the tooltip which is displayed if text is truncated
variant'outline' | 'filled''filled'Variant of the label.

LabelGroup

*required
NameTypeDefaultDescription
addLabelControlReact.ReactNodeControl for adding new labels
aria-labelstring'Label group category'Aria label for label group that does not have a category name
categoryNamestring''Category name text for the label group category. If this prop is supplied the label group with have a label and category styling applied
childrenReact.ReactNodeContent rendered inside the label group. Should be <Label> elements.
classNamestringAdditional classes added to the label item
closeBtnAriaLabelstring'Close label group'Aria label for close button
collapsedTextstring'${remaining} more'Customizeable template string. Use variable "${remaining}" for the overflow label count.
defaultIsOpenbooleanfalseFlag for having the label group default to expanded
editableTextAreaPropsanyAdditional props passed to the editable textarea.
expandedTextstring'Show Less'Customizable "Show Less" text string
hasEditableTextAreabooleanfalseFlag indicating the editable label group should be appended with a textarea.
isClosablebooleanfalseFlag if label group can be closed
isCompactbooleanfalseFlag indicating the labels in the group are compact
isEditablebooleanfalseFlag indicating contained labels are editable. Allows spacing for a text input after the labels.
isVerticalbooleanfalseFlag to implement a vertical layout
numLabelsnumber3Set number of labels to show before overflow
onClick(event: React.MouseEvent) => void(_e: React.MouseEvent) => undefined as anyFunction that is called when clicking on the label group close button
tooltipPosition| TooltipPosition | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end''top'Position of the tooltip which is displayed if the category name text is longer

CSS variables

Prefixed with 'pf-v5-c-label'

Expand or collapse columnSelectorVariableValue
.pf-v5-c-label--pf-v5-c-label--PaddingTop
0.25rem
.pf-v5-c-label--pf-v5-c-label--PaddingRight
0.5rem
.pf-v5-c-label--pf-v5-c-label--PaddingBottom
0.25rem
.pf-v5-c-label--pf-v5-c-label--PaddingLeft
0.5rem
.pf-v5-c-label--pf-v5-c-label--MaxWidth
100%
.pf-v5-c-label--pf-v5-c-label--BorderRadius
30em
.pf-v5-c-label--pf-v5-c-label--BackgroundColor
#f5f5f5
.pf-v5-c-label--pf-v5-c-label--Color
#151515
.pf-v5-c-label--pf-v5-c-label--FontSize
0.875rem
.pf-v5-c-label--pf-v5-c-label__content--before--BorderWidth
1px
.pf-v5-c-label--pf-v5-c-label__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--BackgroundColor
#fff
.pf-v5-c-label--pf-v5-c-label--m-outline__content--before--BorderWidth
1px
.pf-v5-c-label--pf-v5-c-label--m-outline__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label__content--link--hover--before--BorderWidth
2px
.pf-v5-c-label--pf-v5-c-label__content--link--focus--before--BorderWidth
2px
.pf-v5-c-label--pf-v5-c-label__content--link--hover--before--BorderColor
#8a8d90
.pf-v5-c-label--pf-v5-c-label__content--link--focus--before--BorderColor
#8a8d90
.pf-v5-c-label--pf-v5-c-label--m-outline__content--link--hover--before--BorderWidth
2px
.pf-v5-c-label--pf-v5-c-label--m-outline__content--link--focus--before--BorderWidth
2px
.pf-v5-c-label--pf-v5-c-label--m-outline__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-blue--BackgroundColor
#e7f1fa
.pf-v5-c-label--pf-v5-c-label--m-blue__icon--Color
#06c
.pf-v5-c-label--pf-v5-c-label--m-blue__content--Color
#002952
.pf-v5-c-label--pf-v5-c-label--m-blue__content--before--BorderColor
#bee1f4
.pf-v5-c-label--pf-v5-c-label--m-blue__content--link--hover--before--BorderColor
#06c
.pf-v5-c-label--pf-v5-c-label--m-blue__content--link--focus--before--BorderColor
#06c
.pf-v5-c-label--pf-v5-c-label--m-outline--m-blue__content--Color
#06c
.pf-v5-c-label--pf-v5-c-label--m-outline--m-blue__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-blue__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-blue__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-green--BackgroundColor
#f3faf2
.pf-v5-c-label--pf-v5-c-label--m-green__icon--Color
#3e8635
.pf-v5-c-label--pf-v5-c-label--m-green__content--Color
#1e4f18
.pf-v5-c-label--pf-v5-c-label--m-green__content--before--BorderColor
#bde5b8
.pf-v5-c-label--pf-v5-c-label--m-green__content--link--hover--before--BorderColor
#3e8635
.pf-v5-c-label--pf-v5-c-label--m-green__content--link--focus--before--BorderColor
#3e8635
.pf-v5-c-label--pf-v5-c-label--m-outline--m-green__content--Color
#3e8635
.pf-v5-c-label--pf-v5-c-label--m-outline--m-green__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-green__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-green__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-orange--BackgroundColor
#fff6ec
.pf-v5-c-label--pf-v5-c-label--m-orange__icon--Color
#ec7a08
.pf-v5-c-label--pf-v5-c-label--m-orange__content--Color
#3b1f00
.pf-v5-c-label--pf-v5-c-label--m-orange__content--before--BorderColor
#f4b678
.pf-v5-c-label--pf-v5-c-label--m-orange__content--link--hover--before--BorderColor
#ec7a08
.pf-v5-c-label--pf-v5-c-label--m-orange__content--link--focus--before--BorderColor
#ec7a08
.pf-v5-c-label--pf-v5-c-label--m-outline--m-orange__content--Color
#8f4700
.pf-v5-c-label--pf-v5-c-label--m-outline--m-orange__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-orange__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-orange__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-red--BackgroundColor
#faeae8
.pf-v5-c-label--pf-v5-c-label--m-red__icon--Color
#c9190b
.pf-v5-c-label--pf-v5-c-label--m-red__content--Color
#7d1007
.pf-v5-c-label--pf-v5-c-label--m-red__content--before--BorderColor
#c9190b
.pf-v5-c-label--pf-v5-c-label--m-red__content--link--hover--before--BorderColor
#c9190b
.pf-v5-c-label--pf-v5-c-label--m-red__content--link--focus--before--BorderColor
#c9190b
.pf-v5-c-label--pf-v5-c-label--m-outline--m-red__content--Color
#c9190b
.pf-v5-c-label--pf-v5-c-label--m-outline--m-red__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-red__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-red__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-purple--BackgroundColor
#f2f0fc
.pf-v5-c-label--pf-v5-c-label--m-purple__icon--Color
#6753ac
.pf-v5-c-label--pf-v5-c-label--m-purple__content--Color
#1f0066
.pf-v5-c-label--pf-v5-c-label--m-purple__content--before--BorderColor
#cbc1ff
.pf-v5-c-label--pf-v5-c-label--m-purple__content--link--hover--before--BorderColor
#6753ac
.pf-v5-c-label--pf-v5-c-label--m-purple__content--link--focus--before--BorderColor
#6753ac
.pf-v5-c-label--pf-v5-c-label--m-outline--m-purple__content--Color
#6753ac
.pf-v5-c-label--pf-v5-c-label--m-outline--m-purple__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-purple__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-purple__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-cyan--BackgroundColor
#f2f9f9
.pf-v5-c-label--pf-v5-c-label--m-cyan__icon--Color
#009596
.pf-v5-c-label--pf-v5-c-label--m-cyan__content--Color
#003737
.pf-v5-c-label--pf-v5-c-label--m-cyan__content--before--BorderColor
#a2d9d9
.pf-v5-c-label--pf-v5-c-label--m-cyan__content--link--hover--before--BorderColor
#009596
.pf-v5-c-label--pf-v5-c-label--m-cyan__content--link--focus--before--BorderColor
#009596
.pf-v5-c-label--pf-v5-c-label--m-outline--m-cyan__content--Color
#005f60
.pf-v5-c-label--pf-v5-c-label--m-outline--m-cyan__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-cyan__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-cyan__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-gold--BackgroundColor
#fdf7e7
.pf-v5-c-label--pf-v5-c-label--m-gold__icon--Color
#f0ab00
.pf-v5-c-label--pf-v5-c-label--m-gold__content--Color
#3d2c00
.pf-v5-c-label--pf-v5-c-label--m-gold__content--before--BorderColor
#f9e0a2
.pf-v5-c-label--pf-v5-c-label--m-gold__content--link--hover--before--BorderColor
#f4c145
.pf-v5-c-label--pf-v5-c-label--m-gold__content--link--focus--before--BorderColor
#f4c145
.pf-v5-c-label--pf-v5-c-label--m-outline--m-gold__content--Color
#795600
.pf-v5-c-label--pf-v5-c-label--m-outline--m-gold__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-gold__content--link--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-outline--m-gold__content--link--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--Color
#06c
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--BackgroundColor
#fff
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--before--BorderWidth
1px
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--before--BorderColor
#f0f0f0
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--link--hover--before--BorderWidth
2px
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--link--hover--before--BorderColor
#f0f0f0
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--link--focus--before--BorderWidth
2px
.pf-v5-c-label--pf-v5-c-label--m-overflow__content--link--focus--before--BorderColor
#f0f0f0
.pf-v5-c-label--pf-v5-c-label--m-compact--PaddingTop
0
.pf-v5-c-label--pf-v5-c-label--m-compact--PaddingRight
0.5rem
.pf-v5-c-label--pf-v5-c-label--m-compact--PaddingBottom
0
.pf-v5-c-label--pf-v5-c-label--m-compact--PaddingLeft
0.5rem
.pf-v5-c-label--pf-v5-c-label--m-compact--FontSize
0.75rem
.pf-v5-c-label--pf-v5-c-label--m-compact--m-editable--TextDecorationOffset
0.0625rem
.pf-v5-c-label--pf-v5-c-label__content--Color
#151515
.pf-v5-c-label--pf-v5-c-label__content--BackgroundColor
transparent
.pf-v5-c-label--pf-v5-c-label__content--MaxWidth
100%
.pf-v5-c-label--pf-v5-c-label--m-outline__content--Color
#151515
.pf-v5-c-label--pf-v5-c-label--m-editable__content--MaxWidth
16ch
.pf-v5-c-label--pf-v5-c-label__text--MaxWidth
100%
.pf-v5-c-label--pf-v5-c-label__icon--Color
#151515
.pf-v5-c-label--pf-v5-c-label__icon--MarginRight
0.25rem
.pf-v5-c-label--pf-v5-c-label__actions--FontSize
0.75rem
.pf-v5-c-label--pf-v5-c-label__actions--MarginRight
calc(0.5rem * -1)
.pf-v5-c-label--pf-v5-c-label__actions--c-button--FontSize
0.75rem
.pf-v5-c-label--pf-v5-c-label__actions--c-button--MarginTop
calc(0.25rem * -1)
.pf-v5-c-label--pf-v5-c-label__actions--c-button--MarginBottom
calc(0.25rem * -1)
.pf-v5-c-label--pf-v5-c-label__actions--c-button--PaddingTop
0.25rem
.pf-v5-c-label--pf-v5-c-label__actions--c-button--PaddingRight
0.5rem
.pf-v5-c-label--pf-v5-c-label__actions--c-button--PaddingBottom
0.25rem
.pf-v5-c-label--pf-v5-c-label__actions--c-button--PaddingLeft
0.5rem
.pf-v5-c-label--pf-v5-c-label--m-editable--Cursor
pointer
.pf-v5-c-label--pf-v5-c-label--m-editable--TextDecoration
underline
.pf-v5-c-label--pf-v5-c-label--m-editable--TextDecorationStyle
dashed
.pf-v5-c-label--pf-v5-c-label--m-editable--TextDecorationThickness
1px
.pf-v5-c-label--pf-v5-c-label--m-editable--TextDecorationOffset
0.25rem
.pf-v5-c-label--pf-v5-c-label--m-editable--TextDecorationColor
#8a8d90
.pf-v5-c-label--pf-v5-c-label--m-editable--hover--TextDecorationColor
#151515
.pf-v5-c-label--pf-v5-c-label--m-editable--focus--TextDecorationColor
#151515
.pf-v5-c-label--pf-v5-c-label--m-editable__content--before--BorderWidth
1px
.pf-v5-c-label--pf-v5-c-label--m-editable__content--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-editable__content--hover--before--BorderWidth
1px
.pf-v5-c-label--pf-v5-c-label--m-editable__content--hover--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-editable__content--focus--before--BorderWidth
1px
.pf-v5-c-label--pf-v5-c-label--m-editable__content--focus--before--BorderColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-editable--m-editable-active--Cursor
auto
.pf-v5-c-label--pf-v5-c-label--m-editable--m-editable-active--TextDecoration
none
.pf-v5-c-label--pf-v5-c-label--m-editable--m-editable-active--BackgroundColor
transparent
.pf-v5-c-label--pf-v5-c-label--m-editable--m-editable-active__content--before--BorderWidth
0
.pf-v5-c-label--pf-v5-c-label--m-editable--m-editable-active__content--before--BorderColor
transparent
.pf-v5-c-label--pf-v5-c-label--m-disabled--BackgroundColor
#d2d2d2
.pf-v5-c-label--pf-v5-c-label--m-disabled__content--Color
#6a6e73
.pf-v5-c-label--pf-v5-c-label--m-disabled__icon--Color
#6a6e73
.pf-v5-c-label--pf-v5-c-label--c-button--m-disabled--Color
#6a6e73
.pf-v5-c-label.pf-m-compact--pf-v5-c-label--PaddingTop
0
.pf-v5-c-label.pf-m-compact--pf-v5-c-label--PaddingRight
0.5rem
.pf-v5-c-label.pf-m-compact--pf-v5-c-label--PaddingBottom
0
.pf-v5-c-label.pf-m-compact--pf-v5-c-label--PaddingLeft