Add content property
See the Development process to load a base element in dev mod.
We will add a title property on our section, so that the user can dynamically change the title of the section.
ww-config.js
The first step is to declare this property on the properties
field of the configuration:
js
properties: {
// [...]
title: {
label: {
en: "Title",
},
type: "Text",
defaultValue: "My title",
},
}
Use the value inside the template
html
<div class="my-element">
<h1>{{ content.title }}</h1>
<p :style="textStyle">I am a custom element !</p>
</div>
And that's all!
TIP
In this use case, it might be better to use a WeWeb text so the user can edit all the text style.