Tag
Overview
Use the tag component to display one or more values that provide additional context for an activity.
Responsive UI supports two use cases for tags: displaying metadata and displaying search filters.
Metadata tags
The first use case is displaying a list of metadata values for an element. Let’s say I publish a blog post and want to add metadata tags to my post to help categorize it. I could add values like “javascript”, “web components”, and “security”, and anyone reading this post would have a better idea of the topics it covers.
These metadata tags may or may not be clickable. In the blog post example, it might be helpful to allow the user to click one of the metadata tags to, say, find all blog posts on that topic.
Search filter tags
The second use case is displaying a list of search filter tags. Let’s say I’m performing a complex search based on multiple search filters. If the search view displays each search filter as a clickable, closable tag, I can simply click any of the search filter tags to remove it and widen my search results.
The list of search filter tags can also optionally include a “CLEAR ALL” option, allowing me to quickly remove all filters from the search.
You should display search filter tags above the search results since they help control which data displays.
You should typically hide search filter tags on mobile devices. They can take up a lot of room at smaller screen widths, and since they are a secondary level of control (the primary being the search inputs), they should be hidden in this case.
Development
Web component development
Component reference
rui-tag-button
Displays a list of metadata or search filter tags
Name | Type | Default | Description |
---|---|---|---|
text | string | '' | Text displayed in tag |
isClickable | boolean | false | Specifies whether the user can click the tag |
isClosable | boolean | false | Specifies whether the user can close the tag |
rui-click | event | Event fired when the user clicks the tag |
Implementation
Begin by importing the rui-buttons
module into your application.
Let’s start by defining two different string arrays in the view’s TypeScript: one with a list of metadata tags and another with a list of search filter tags.
Metadata Tags
Now let’s create an example of a simple, non-clickable tag list that displays metadata tags. We add an rui-tag-button for each tag in the list. Tags are non-clickable by default.
Now let’s create an example of a clickable tag list that displays metadata tags. This is the same as the previous example, except we include isClickable=“true” and specify an event handler for the rui-click event.
Search Filter Tags
Now let’s create an example of a list of search filter tags. The user can click each tag button to remove it from the list. This is similar to the previous example, except we include isClosable=“true”.
And last, let’s create an example of a list of search filter tags that includes a “CLEAR ALL” option. This allows the user to clear the entire list at once. The implementation is the same as the previous example, although we include an extra tag with the text “CLEAR ALL” that clears the list of tags when clicked.
Angular wrapper development
Wrapper reference
jha-tag-button
Displays a list of metadata or search filter tags
Name | Type | Default | Description |
---|---|---|---|
jhaText | string | '' | Text displayed in tag |
jhaIsClickable | boolean | false | Specifies whether the user can click the tag |
jhaIsClosable | boolean | false | Specifies whether the user can close the tag |
jhaClick | event | Event fired when the user clicks the tag |
jha-tag-close-button
Adds a close button to closable tags
Implementation
Begin by importing the JhaButtonsModule into your application.
Let’s start by defining two different string arrays in the view’s TypeScript: one with a list of metadata tags and another with a list of search filter tags.
Metadata Tags
Now let’s create an example of a simple, non-clickable tag list that displays metadata tags. We add a jha-tag-button for each tag in the list. Tags are non-clickable by default.
Now let’s create an example of a clickable tag list that displays metadata tags. This is the same as the previous example, except we include [jhaIsClickable]=“true” and specify an event handler for the jhaClick event.
Search Filter Tags
Now let’s create an example of a list of search filter tags. The user can click each tag button to remove it from the list. This is similar to the previous example, except we include [jhaIsClosable]=“true”.
And last, let’s create an example of a list of search filter tags that includes a “CLEAR ALL” option. This allows the user to clear the entire list at once. The implementation is the same as the previous example, although we include an extra tag with the text “CLEAR ALL” that clears the list of tags when clicked.
Design
Figma design
Dev Component | Design Component Name |
---|---|
Tag | RUI / Tag Available values for the Interactivity property:
|
Metadata tags are either clickable or non-clickable.
Search filter tags are closable. You can optionally add a clickable “CLEAR” tag to the right of all closable search filter tags if you want the user to be able to clear all the search filters at once.
Adobe XD design
- Sample App - Tags
Dev Component | Design Component Name |
---|---|
Tag - non-clickable | JHA / Tags / Tag / Non-Clickable |
Tag - clickable | JHA / Tags / Tag / Clickable |
Tag - closable | JHA / Tags / Tag / Closable |
Metadata tags are either clickable or non-clickable.
Search filter tags are closable. You can optionally add a clickable “CLEAR” tag to the right of all closable search filter tags if you want the user to be able to clear all the search filters at once.