I sometimes see folks creating components in XM Cloud incorrectly. Therefore I decided to create and share this guidance with you.
So, basically, there are five steps involved in creating your own component:
- Create an SXA module that will serve as a pluggable container for all the necessary assets for your components, if not done yet.
- The easiest way to create a component is to clone a mostly matching existing one. If you need to rely on datasource items, clone the one that already leverages datasource. SPE scaffolding script will do the rest of the job for you. Make sure you assign a newly created component to a module from Step 1 above.
- Now, having a module with component(s), you need to make it visible for your website, but adding a module to a chosen site. This empowers your site to see a corresponding section in the toolbox with newly created component(s) for you to use straight away, for both Experience Editor and Pages.
- You need to ensure the
Component Namefield is referencing the name of corresponding TSX codebase files as
/src/<jss_app>/src/components/<your component>.tsxor one more level down within a folder with the same name as the component is. Since the component is fully cloned from the existing one, you can also copy the original TSX files under a new name and it will work straight away.
- Don’t forget to add all the new locations to the serialization, and check it into source control along with its codebase. Here are the locations to keep in mind:
/sitecore/layout/Placeholder Settings/Feature/Tailwind Components
/sitecore/media library/Feature/Tailwind Components
XM Cloud Roadmap Guide
XM Cloud is the future of enterprise content management offerings. The new sites, pages, and components tools offer an efficient content author experience that is not available with other CMS systems.
To make things simple, I recorded this entire walkthrough (and actually “talkthrough”) showing the entire process:
Hope you find this video helpful!