Skip to main content

Multi-Select Field

type: "multi-select"

A select of predefined options, of which users can pick any number. Use it for choices that aren't exclusive, like which parts of a widget to show.

Additional Properties​

PropertyTypeRestrictionsDescription
optionsValueOptionsRequiredThe options users can pick from.
defaultValuestring[]-The values of the options picked by default.

Options can show an icon next to their label.

The value of the field is the list of picked values, in the order they were picked. While users haven't touched the field, the options of the defaultValue are picked. Once users change the selection, it's kept as it is, even if they remove every option: an empty selection doesn't fall back to the defaultValue. Clearing the field with the clear button brings the defaultValue back.

Example​

mobro-widget-config.json
{
"config": [
{
"name": "visible_parts",
"label": "Show",
"type": "multi-select",
"defaultValue": ["label", "value"],
"options": [
{"label": "Label", "value": "label", "icon": "md/MdLabel"},
{"label": "Value", "value": "value", "icon": "md/MdNumbers"},
{"label": "Unit", "value": "unit"},
{"label": "Min / Max", "value": "min_max"}
]
}
]
}

Usage​

To read the picked values in a widget, use useMultiSelectField.

To show or hide other fields depending on the picked options, use the includes, includesAny and includesAll checks of conditional visibility.