Overview
TheRelatedTags component renders a set of clickable tags that help users refine their search results. After searching for a broad term like “lego”, users can select related tags like “city”, “friends”, or “harry potter” to narrow results to “lego city”, “lego friends”, or “lego harry potter”.
When to Use
Use the RelatedTags component to:- Help users refine broad search queries
- Display category or attribute-based filters as tags
- Provide quick access to popular search refinements
- Improve search precision without complex facet interfaces
Installation
Import the component from the related-tags module:Basic Usage
The component automatically displays related tags after a search is performed:Props
Animation component that will be used to animate the tags. Pass a Vue animation component to add entrance effects.
Number of related tags to be rendered. If not specified, all available tags from the state will be displayed.
Flag to indicate if curated tags should be displayed differently from algorithmic ones. When true, curated tags can have distinct styling.
CSS class(es) to be applied to each tag element. Useful for consistent styling across tags.
Slots
related-tag Slot
Customize the entire related tag component including wrapper and behavior. Slot Props:relatedTag(RelatedTag) - The related tag datahighlightCurated(boolean) - Whether curated tags should be highlighted
related-tag-content Slot
Customize only the content inside each tag. Slot Props:relatedTag(RelatedTag) - The related tag dataisSelected(boolean) - Whether this tag is currently selectedshouldHighlightCurated(boolean) - Whether this specific tag should be highlighted
Events
The component emits events through the event bus:- UserSelectedARelatedTag: Emitted when a user clicks on a related tag
- UserDeselectedARelatedTag: Emitted when a user clicks on an already selected tag
Examples
Basic Example
Display related tags with default styling:With Animation and Limit
Add animations and limit the number of displayed tags:Custom Tag Content
Customize the appearance of tag content:With Custom Styling Classes
Apply custom CSS classes to tags:Integrated with Results
Combine related tags with search results for a complete search experience:Integration Tips
Tags can be selected and deselected. When a tag is selected, the search query is automatically refined. Multiple tags can be active simultaneously.
Curated vs Algorithmic Tags
Related tags can be:- Algorithmic: Generated automatically based on search results and user behavior
- Curated: Manually configured by merchandisers for specific queries
highlightCurated prop to visually distinguish curated tags, helping users identify editorially recommended refinements.
Styling
The component uses these CSS classes:.x-related-tags- Main container (flex layout).x-related-tags__item- Individual tag wrapper.x-related-tag- Tag component itself
display: flex and flex-flow: row nowrap.
Accessibility
Related tags are interactive buttons that can be selected with keyboard navigation. Ensure your custom implementations maintain keyboard accessibility.Related Components
- Next Queries - Show related query suggestions
- Facets - Advanced filtering interface
- Popular Searches - Display trending searches
