Skip to main content

Configurable Widget Fields

The config array in the mobro-widget-config.json defines the fields users can configure for a widget. The dashboard builder generates a form in its sidebar from these fields, and the widget reads the values using the corresponding field hooks.

Field Types​

TypeInput in the dashboard builderHook to read the value
stringText inputuseStringField
numberNumber inputuseNumberField
sliderSlider with a number input, within a rangeuseSliderField
checkboxSwitchuseCheckboxField
selectSelect of predefined optionsuseSelectField
radioRadio buttons of predefined optionsuseSelectField
button-groupRow of toggle buttons, optionally with iconsuseButtonGroupField
multi-selectSelect of predefined options, several can be pickeduseMultiSelectField
fileFile uploaduseFileField, useFilesField
fontFont selectuseFontField
metricMetric selectuseMetricField
colorColor pickeruseColorField
repeaterList of items, each with its own set of fieldsuseRepeaterField
actionAction selectuseActionField
separatorLabeled separator (deprecated, not a field)-

The options of select, multi-select and button-group fields can show icons from Strato and the react-icons sets Material Design (md/), Tabler (tb/), Lucide (lu/) and Font Awesome 6 (fa6/), see Icons.

Common Properties​

All fields share the following properties:

PropertyTypeRestrictionsDescription
typestringRequired
One of the field types above
The type of the field.
namestringRequired
Pattern: ^[\w-]+$
Unique within the widget
The identifier of the field, used to read its value.
labelstring-The label shown in the dashboard builder.
descriptionstring-A hint about the field, shown as tooltip in the dashboard builder.
defaultValue-Depends on the field typeThe value of the field when a widget is added to a dashboard.
visibleIfCondition-Only shows the field while the condition on the values of other fields passes, see Conditional Visibility.
hideIfCondition-Hides the field while the condition on the values of other fields passes.

Additional properties depending on the field type are described on the page of each field type.

note

The JSON schema also allows a value property on every field. It's used by MoBro internally; don't set it in the mobro-widget-config.json.

Example​

A mobro-widget-config.json with two configurable fields:

mobro-widget-config.json
{
"name": "my_widget",
"displayName": "My Widget",
"filename": "MyWidget.tsx",
"config": [
{
"name": "title",
"label": "Title",
"type": "string"
},
{
"name": "show_title",
"label": "Show title",
"description": "Whether the title is shown above the value",
"type": "checkbox",
"defaultValue": true
}
]
}

To structure many fields in the dashboard builder, e.g. using tabs or by putting fields side by side, see Configurable Widget Layout. To show fields only when they're relevant, see Conditional Visibility.

Besides fields, the config array can contain markdown texts to explain the fields, and separators.