Labels
Elements
You can further customize labels by making them filled or unfilled, dismissable, adding icons, or making them clickable links. You can use any combination of these elements in a single label.
![Examples of different label features](/images/label-features.9d25d05f56bf2137.png)
- Fill/Unfilled labels: Offer customization for emphasis.
- Dismissible label: Can be dismissed by clicking on the “x”.
- Label with icon: Can be used to further clarify the label.
- Clickable labels: Has a hover state to show interactiveness.
- Editable labels: Has a dashed underline to communicate editability.
Usage
Use a label when you want to highlight an element on a page to draw attention to it or make it more searchable. Labels can also be used to tag items of the same category. If you want to show a count, use a badge instead.
There are 2 specific label types:
![Different label types](/images/label-features-type.eab49bf89b37f162.png)
- Default labels: Use by default when needing a label.
- Compact labels: Use when confronted by space limitations and a smaller label is required (for example, in a table).
Labels can be used almost anywhere in a UI, but are commonly used in table views and catalogs as shown below.
![Example labels in a table](/images/label-table-view.c45da24344a20dbf.png)
![Example labels in a catalog](/images/catalog-view.9e767ed38a888dd0.png)
Color considerations
Both default and compact labels come in the following default colors: gray, blue, green, orange, red, purple, and cyan. We offer a wide array of colors to allow for color coding labels within UIs. Label colors can be used to indicate status if desired, but do not have to. Regardless, we recommend you avoid using the red label unless it indicates danger or an error state.
![Label colors](/images/filled-labels.3c14bbc615094f69.png)
While you may use other colors for your labels, we recommend using the ones provided as they have been carefully selected to be accessible with the PatternFly library. If you choose to use other colors, be mindful of picking accessible text color and icon color to go with the label background.
Variations
When to use filled or unfilled labels
Use the filled option to add more visual prominence to a label. If your use case requires a mix of clickable and non-clickable labels, consider using one type for clickable and another for non-clickable. Whatever convention you choose, be sure to maintain consistency through your UI.
- Unfilled
![Unfilled labels](/images/unfilled-labels.b32a543adfbf0402.png)
- Filled
![Filled labels](/images/filled-labels.3c14bbc615094f69.png)
Use the filled option to add more visual prominence to a label.
When to use dismissable labels
Use a dismissable label for labels that are easily removed. A common use case for dismissable labels is when users can edit labels.
![Example of dismissable labels](/images/edit-labels.6474dd679e61f541.png)
When to use labels with icons
Add an icon to your label in cases where additional visual information is helpful. You can also use them to distinguish labels of the same color if needed.
![Example of different colored labels with icons](/images/labels-with-icons.48d897355aec002c.png)
When to use clickable labels
Use a clickable label for actionable labels. A common use case for clickable labels is when a user may want to filter by a specific label. You can also use label links to redirect users to a new page.
![Example of a clickable label](/images/clickable-label.85f10025405ed989.png)
When to use editable labels
Use editable labels when you want to allow users to organize and select resources manually. Adding editable labels enables the user to query for objects that have similar, dissimilar, or overlapping labels.
![Example of a editable label](/images/editable-label-feature.7358ad7784aee92c.png)
Label groups
Label groups are used to display multiple labels at once.
Elements
Label groups have a number of components to them.
![Elements of a label group](/images/label-group-elements.c8ece50762f93cf9.png)
- Group category (optional): indicates the group category
- Label: indicates the labels applied.
- Overflow: indicates if there are more labels to show.
- Group close (optional): deletes the entire label group.
Label groups can use various combinations of these features to build custom label groups.
Usage
Label groups should be used when there are multiple labels assigned to a component. They can be used almost anywhere in a UI, but are commonly used in table views and description lists. Label groups can be oriented either horizontally or vertically and can optionally be named and be dismissable. You may also make the label group editable to allow users to edit an existing label or add a new label.
Label groups in a table
![Table with labels](/images/table-view.8a07524507679e44.png)
Label groups in a table popover
![Table with vertical label group in a popover](/images/table-view-2.f9c878a66d1f161d.png)
Label groups in a description list
![Description list with labels](/images/description-list.0abad09ff4a6df9a.png)
Variations
Editable label group
Adding a new label to a group, without a group label
This variation can be used when there is a need to add a new label or edit an existing label within a label group, and the label group does not have a group label.
![Adding a new label to a group without a group label](/images/editable-label-group-in-a-table_1.3914dfa342ad3960.png)
When the user selects the ‘Add label’ button, a new label is added as the first label in the group. Once the new label is added, the user can overwrite the default value by double clicking the label.
Adding a new label to a group, with a group label
This variation can be used when there is a need to add a new label within the label group, and the label group has a group label.
![Add a new label to a group with a group label](/images/editable-label-group-in-a-table_2.5f2771d4772d671c.png)
When the user selects the ‘Add label’ button, a new label is added as the first label in the group. Once the new label is added, the user can overwrite the default value by double clicking the label.
Adding a new label to a label group from a list of preselected labels
This variation can be used when only a fixed set of labels can be added to a label group.
When the user selects the ‘Add label’ button, a drop list is displayed with the existing list of values. User selects a new label from the values in the drop list.
The new label is added with the selected value and can not be changed.
Adding a new custom label to a label group
This variation can be used when you want to allow users to customize the labels they add to a label group.
When the user selects the ‘Add label’ button, it opens up a modal from which they can select the attributes for the new label. These include label text, color, icon, filled vs outlined, ability to dismiss, and editability. The options shown can be customized to fit your use cases.
The new label is created based on the attributes selected by the user and it can not be changed.
Accessibility
For information regarding accessibility, visit the labels accessibility tab.