Create custom styled widget components
Sitecore Search UI Components package includes templates of styled widget components that are widget components built with UI components primitives and styles. You can edit the styles in these components or replace entire components.
To create a custom styled query hooked recommendation widget component:
-
In the UI components reference site, in the Widget templates section, open the Search results page.
-
In your React project, in the
widget_componentsfolder, create a folder namedsearchResultsBasicStory. -
From the list of templates, in the Basic story page, click
index.jsto copy the code block. -
In the
searchResultsBasicStoryfolder, create a JavaScript file calledindex.js, then paste the copied code block into it, and save. -
From the list of templates, in the Basic story page, click
styled.jsto copy the code block. -
In the
searchResultsBasicStoryfolder, create a JavaScript file,styled.jsthen paste the copied code block into it, and save. -
In
styled.js, edit the styled primitives, and save. -
In your
applicationcomponent, add component as shown in the following code block. -
To avoid compile errors, update the imports section, and save.
React resources for your implementation:
-
To view working examples of Discover widgets, visit the starter kit website built using Search JS SDK and UI components packages.
-
You can download or fork its GitHub repository.
-
The Search Search UI components reference lists all available widget templates, UI components, and theming variables.
-
Use the UI components CLI to replicate widget templates in your IDE.