Thursday 18 April 2024

Coveo for Sitecore :: Creating a custom toggle facet

 In a recent project I was working on, we needed to create a custom Coveo for Sitecore facet which looks like a toggle, if you know Coveo for Sitecore Hive OOTB components you probably know that OOTB we don't have such a component, so, we would need to create a custom implementation for such component, if you got excited, keep reading! 



The output result we're targeting is to have a toggle Coveo facet that looks similar to the below component, we also want to work with a custom values (not required a 0/1 true/false) so lets how I accomplished that. 

Below is a sample HTML of how you can style a checkbox input to look like a toggle component, with simple html and styling you can accomplish the look needed: 

Now all what you need to do is to use Coveo for Sitecore JS framework, utilizing Coveo events, such as after initialization event, building query query event, & clear breadcrumb Breadcrum events to achieve the desired state, you can notice below that I'm passing a Yes value to my predefined faceted field. 



Hopefully the above help you in your challenge or give you an idea how you can build your own custom Coveo component.   

No comments:

Post a Comment