What You’ll Learn
- how elements are used in Page Builder theme
- how to update elements in Page Builder theme
Another way Webiny Page Builder ensures that visual styles follow your design system is by having certain style presets for some of the elements like the Button element as shown below:
Elements are defined in the
elements section of the
It defines certain attributes for Page Builder elements that you can insert into your page content.
Currently, only the following elements support this, for example:
But the point is that if you create a custom component for Page Builder, you can reference the same mechanism and add this functionality to your custom elements.
The definition takes two keys:
className: Name of the CSS class that gets appended to that element.
label: This is what's shown in the dropdown when a user is selecting a style.
In the case of the
button element, the
types attribute contains available button types.
Each type references a specific class name that gets added to the button component when that type is selected.
By default, Webiny uses BEM naming.
The default button class is
webiny-pb-element-button, so when the user selects the
primary button type,
it adds a modifier of
primary to the base class, meaning the resulting class name becomes
We achieve this in two steps:
- Add a new item in button types
- Add styles corresponding to that type
Make the following change in
Make the following changes in
With these changes in place, the
button element gets a new type available to use in the Page Builder editor as shown below: