<ws-suggest> component is used to display search suggestions within a search box. The individual suggestions are displayed as a list and can be selected by mouse click or via the keyboard (arrow keys for navigation, Enter to select).
Optionally, an additional “Show all results” element can be shown at the end of the list, which is treated like a regular suggestion. When selected, a search with the current search term is triggered. The placeholder {%query%} in show-all-message is dynamically replaced with the entered search term.
Component
The component can be embedded within<ws-search-box> to control the display of the suggest box:
- Attributes
suggest-container-class– Specify CSS class(es) for the container of the suggest box.suggest-item-class– Specify CSS class(es) for the suggest items.use-show-alltrue/yes– Activates the additional “Show all” element (show all results) at the end of the suggestion list.
show-all-class– Specify CSS class(es) for the “Show all” element.show-all-message– Display text for the “Show all” element. In the display text,{%query%}can be replaced with the current search term. Default:Show all results for: '{%query%}'.
The attributes
use-show-all, show-all-class, and show-all-message are only relevant in the simple mode (without <ws-suggest-result>). In orchestrator mode, show-all is configured via a <ws-suggest-result source="show-all"> element.Orchestrator mode
As soon as<ws-suggest> contains at least one <ws-suggest-result> child element, Orchestrator Mode is activated automatically. In this mode, <ws-suggest-result> takes over control of the display per result type (for example search suggestions, products, categories).
Further details on the configuration of <ws-suggest-result> are described here.
suggest-container
Thesuggest-container attribute can be set on any HTML element. This causes that element (including all child elements) to be hidden and shown together with the associated <ws-suggest-result> – for example, to hide section headings together with the result area because no results are available.
Example
Mustache delimiters in templates
Since the VX template engine uses{{ }} as delimiters, which leads to conflicts with the Mustache rendering of the components, different delimiters are used in all web component templates:
Webcomponents (ws-suggest, ws-suggest-result, …)uses{% %}VX template engineuses{{ }}
Styling via CSS
If no own CSS classes are specified via the component, the search sets default classes:suggestionssuggestion-itemshow-all-item
