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 element | Description | Contains |
|---|---|---|
fieldset | A group of fields, optionally collapsible | Field names and layout elements |
tabs | A set of tabs | tab elements only |
tab | A single tab within tabs | Field names and layout elements |
row | Columns side by side | column elements only |
column | A single column within a row | Field names and layout elements |
separator | A labeled separator | - |
markdown | A 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:
{
"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"
]
}
]
}