Button Group Field
type: "button-group"
A row of toggle buttons, of which one is selected. Like a radio field, it shows all options at once, but it takes much less room and the buttons can show icons. It suits a few short options, like an alignment or a direction.
Additional Properties
| Property | Type | Restrictions | Description |
|---|---|---|---|
| options | ValueButtonOptions | Required | The buttons users can select from. |
| defaultValue | string | - | The value of the button selected by default. |
Unlike the options of a select field, a button doesn't need a label. A button with only an icon shows just the icon,
which works well for alignments and similar choices. A button with neither a label nor an icon shows its value.
While users haven't picked a button, the button of the defaultValue is shown as selected. Users can clear their choice
with the clear button next to the group, which brings back the defaultValue.
Icons
The icon of a button references an icon of Strato or of any
react-icons set, prefixed with the icon set: LineChartIcon or strato/LineChartIcon for
Strato, md/MdHome, fa6/FaHouse or lu/LuAlignLeft for react-icons. See Icons for all prefixes.
Example
{
"config": [
{
"name": "text_align",
"label": "Alignment",
"type": "button-group",
"defaultValue": "left",
"options": [
{"value": "left", "icon": "lu/LuAlignLeft"},
{"value": "center", "icon": "lu/LuAlignCenter"},
{"value": "right", "icon": "lu/LuAlignRight"}
]
},
{
"name": "size",
"label": "Size",
"type": "button-group",
"defaultValue": "m",
"options": [
{"label": "S", "value": "s"},
{"label": "M", "value": "m"},
{"label": "L", "value": "l"}
]
}
]
}
Usage
The value of a button group field is the value of the selected button. To read it in a widget, use
useButtonGroupField.