Your first widget
Create a widget in the admin, add it to a page and change its settings.
On this page
This example creates Greeting: a framed line with an editable word and a name that the user sets in the settings.
Create the widget
- Open Widgets.
- Click Options and choose Create. The Source-code window opens with a template of a new widget.
- Replace the whole text with the code below and click SUBMIT.

<script total>
exports.id = 'greeting';
exports.name = 'Greeting';
exports.author = 'Jane Doe';
exports.version = '1';
exports.config = { name: 'World', align: 'left' };
</script>
<style>
.CLASS-box { padding: 20px; border: 1px solid #E0E0E0; border-radius: var(--radius); font-size: 18px; }
.CLASS-center { text-align: center; }
</style>
<settings>
<div class="padding">
<div class="m">
<ui-component name="input" path="?.name" config="required:1">Name</ui-component>
</div>
<ui-component name="input" path="?.align" config="dirsource:left|Left,center|Center">Align</ui-component>
</div>
<script>
exports.save = function(config, el) {
var box = el.find('.CLASS-box');
box.find('b').text(config.name);
box.tclass('CLASS-center', config.align === 'center');
};
</script>
</settings>
<body>
<div class="CLASS-box"><span class="CMS_edit">Hello</span> <b>World</b></div>
</body>Greeting appears on the Widgets screen. A widget without a preview image shows an empty picture there.
The identifier greeting must be unique. If another widget already has it, saving replaces that widget.
Add it to a page
- Open a page in the visual editor.
- Click the content area and choose Add a widget.
- Click Greeting.

The word Hello has the class CMS_edit, so the user can click it and choose Edit to change it. World has no such class: it changes only through the settings.
Change the settings
- Click the widget and choose Widget settings, the gear button.
- Enter a name and choose Center in Align.
- Click APPLY.

The function exports.save writes the name into the b element and adds the class for the alignment. CMS stores the values in the page with the instance. Save the page.
See it on the public site
Open the page. The visitor sees the frame and the text:
<div class="w-greeting CMS_mv CMS_mh" data-cms-id="mwnhgevf">
<div class="w-greeting-box"><span>Hello</span> <b>World</b></div>
</div>CMS removes the CMS_ classes of the editor and the data-cms attribute. It keeps the margins CMS_mv and CMS_mh and the class of the widget.
Change the widget
On the Widgets screen, click Greeting (or its gear button and Edit). Change the code and click SUBMIT. CMS compiles the widget again, and every page uses the new styles, settings and server code at once.
Keep the same exports.id when you edit a widget. Pages refer to the widget by its identifier, and an instance whose widget does not exist is left out of the public page. The editor also removes such instances when it opens the page.