Containers
Make a component that holds other components, such as a box with a title.
A container is a component with one or more areas where the user drops other components. Container, Columns, Tabs and Form are containers. This page builds Card, a box with a title.

Mark the area
An element with the class UI_components and a data-index is an area. UI Builder puts the components that the user drops there into it, in the editor and in the published design.
editor.html:
<style>
.CLASS_title { font-size: 15px; font-weight: bold; margin-bottom: 10px; }
.CLASS .UI_components { min-height: 40px; }
</style>
<script>
exports.id = 'card';
exports.name = 'Card';
exports.group = 'Demo';
exports.author = 'Jane Doe';
exports.icon = 'ti ti-address-card';
exports.version = '1';
exports.config = { title: 'Card title' };
exports.render = 'auto';
exports.settings = '<div class="padding"><ui-component name="input" path="?.title">Title</ui-component></div>';
exports.make = function(instance, config, element, cls) {
element.html('<div class="UI_border"><div class="{0}_title"></div><div class="UI_components" data-index="0"></div></div>'.format(cls));
instance.on('configure', function() {
element.find('.' + cls + '_title').text(config.title);
});
instance.emit('configure');
};
</script>
<readme>
A box with a title. Drop other components inside it.
</readme>render.html:
<style>
.CLASS_title { font-size: 15px; font-weight: bold; margin-bottom: 10px; }
</style>
<script>
exports.id = 'card';
exports.make = function(instance, config, element, cls) {
element.html('<div class="UI_border"><div class="{0}_title"></div><div class="UI_components" data-index="0"></div></div>'.format(cls));
element.find('.' + cls + '_title').text(config.title);
};
</script>- The editor needs a
min-heighton the empty area, or the user cannot drop anything into it. - A component with several areas numbers them
data-index="0",data-index="1"and so on, as Columns does. - The published design must create the same areas with the same numbers, or the components inside are not shown.
UI_borderandUI_labelare classes of the templates: a thin border with padding, and the small label above a container.
The components inside
In code, the instance knows the instances inside it:
instance.children: the instances directly inside it.instance.family(): all instances inside it, at every level.instance.family(1)returns those of the area withdata-index="1".instance.parent: the instance that holds this one.
A Form reads instance.family() in its ready handler and collects their values.
A component that brings its own content
Export to component makes a container that brings the components it was made from. Its declaration lists them in exports.children and the components it needs in exports.components. See Export to component. The user cannot change the components inside such an instance.