---
title: Containers
project: UI Builder
version: 1.0
section: development
language: en
license: MIT
url: https://totaljs.es/docs/uibuilder/1-0/development/containers/
updated: 2026-11-19T11:56:06.259Z
---

# 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.

![The editor with a Form that holds a Stepper, and a Card titled Extras that holds a second Stepper](/files/Jaq7LV63s60f.webp)

## 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`:

```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`:

```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-height` on 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_border` and `UI_label` are 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 with `data-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](/uibuilder/1-0/guides/export-to-component/). The user cannot change the components inside such an instance.
