Let custom components react instantly to style changes in Page builder
In Page builder Editor mode, when a user changes the styles of a component in the right-hand styling panel, seeing the style changes in the canvas sometimes requires a page reload, which can be disruptive.
To avoid this, you can make a component subscribe to an event containing:
instanceId- That identifies the component instance on the canvas.cssClasses- The updated CSS class string.
For a component to subscribe to the event, add the following code to your component:
The solution is event-driven, non-breaking, and opt-in per component. Components that need style-driven runtime recalculation can subscribe and react without forcing full canvas reloads. Make sure you use the exact browser event name dispatched by the platform sitecore:component-style-change.
For example:
If you have suggestions for improving this article, let us know!