Create custom styled merchandising widget components
Sitecore Discover 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 Recommendation page.
-
In your React project, in the
widget_componentsfolder, create a folder namedcarouselStyled. -
From the list of templates, in the Styled carousel page, click
index.jsto copy the code block. -
In the
carouselStyledfolder, create a JavaScript file calledindex.js, then paste the copied code block into it, and save. -
From the list of templates, in the Styled carousel page, click
styled.jsto copy the code block. -
In the
carouselStyledfolder, 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.RequestResponseimports ( Recommendation ) from "./widget_components/carouselStyled"; const MyApp = () => { return ( <WidgetsProvider env='<environment>' customerKey='<customer key>' apiKey='<api key>' useToken > <Recommendation rfkId="styled_recommendation" /> </WidgetsProvider> ) }; -
To avoid compile errors, update the imports section, and save.