Skip to main content

Configurable Widget Layout

By default, the dashboard builder lists all configurable fields of a widget from top to bottom, in the order they are defined in the config array. With many fields, this list becomes long and hard to use.

The optional layout array in the mobro-widget-config.json structures the fields using tabs, fieldsets, rows and columns, and adds separators and explanations between them.

Layout Definition​

The layout array contains the names of fields and layout elements. Layout elements can contain fields and other layout elements.

Layout elementDescriptionContains
fieldsetA group of fields, optionally collapsibleField names and layout elements
tabsA set of tabstab elements only
tabA single tab within tabsField names and layout elements
rowColumns side by sidecolumn elements only
columnA single column within a rowField names and layout elements
separatorA labeled separator-
markdownA text formatted as Markdown, e.g. a hint-

Every layout element can be shown or hidden depending on the values of fields with visibleIf and hideIf. Hiding a layout element hides everything in it, see Conditional Visibility.

Fields that are not referenced in the layout are listed after the layout. Separators in the config array are ignored when a layout is defined, and so are markdown texts without a name.

The config and layout of a repeater field work the same way, for the fields of each repeater item.

Example​

A widget with three fields, two of which are grouped in a fieldset:

mobro-widget-config.json
{
"name": "my_widget",
"displayName": "My Widget",
"filename": "MyWidget.tsx",
"config": [
{
"name": "title",
"label": "Title",
"type": "string"
},
{
"name": "center_vertically",
"label": "Center vertically",
"type": "checkbox"
},
{
"name": "center_horizontally",
"label": "Center horizontally",
"type": "checkbox"
}
],
"layout": [
"title",
{
"type": "fieldset",
"label": "Alignment",
"children": [
"center_vertically",
"center_horizontally"
]
}
]
}