Field type
checkbox-group
Multi-select control. Alias button-group renders the same control with different visual styling. Use when authors need to pick zero or more options from a fixed list.
Type: checkbox, checkbox-group (alias listed in the doc) · Stored attribute type: boolean
Stored value
array of strings — the selected option values
Supports
- Multi-select from a fixed list of options
- Two visual styles via the alias
button-group(same stored shape) - Default selection via
defaultarray
Config options
| Option | Type | Default | Description |
|---|---|---|---|
options | { value, label }[] | The choices. Required. | |
default | string[] | Pre-selected values. Empty array if omitted. |
Gotchas
- For single-select use
toggle-group. The controls are picked by the SHAPE of the saved value: array of strings (multi) vs single string (single).
Example
{ "id": "ctrl_categories",
"type": "checkbox-group",
"label": "Show categories",
"attributeKey": "categories",
"default": ["design"],
"options": [
{ "value": "design", "label": "Design" },
{ "value": "engineering", "label": "Engineering" },
{ "value": "product", "label": "Product" }
],
"parentPanelId": "panel" }Consume
JSX
export default function Filters({ attributes }) {
const cats = Array.isArray(attributes.categories) ? attributes.categories : [];
return (
<ul>
{cats.map((c) => <li key={c}>{c}</li>)}
</ul>
);
}PHP
<?php
$cats = is_array($attributes['categories'] ?? null) ? $attributes['categories'] : [];
?>
<ul>
<?php foreach ($cats as $c): ?>
<li><?php echo esc_html($c); ?></li>
<?php endforeach; ?>
</ul>Every field also takes the keys common to all fields.