GCBGutenberg
Control Blocks
Buy

Field type

toggle / toggle-group

Two related controls. toggle is an on/off switch storing a boolean. toggle-group is a single-select segmented control storing the chosen value as a string.

Type: toggle, toggle-group (alias listed in the doc) · Stored attribute type: boolean

Stored value

boolean (toggle) or string (toggle-group)

Supports

  • Simple on/off boolean via toggle
  • Single-select segmented control via toggle-group
  • Pairs naturally with conditionalLogic to gate other fields

Config options

OptionTypeDefaultDescription
options{ value, label }[]toggle-group only. The choices shown as segments. Required for toggle-group.
defaultboolean or stringFor toggle a boolean; for toggle-group the pre-selected value (should match one of the options or no segment will be active).

Gotchas

  • For multi-select use checkbox-group (alias: button-group). The two are picked by the SHAPE of the saved value, not by visual style.

Example

JSON
// toggle
{ "id": "ctrl_pinned",
  "type": "toggle",
  "label": "Pin to top",
  "attributeKey": "is_pinned",
  "default": false,
  "parentPanelId": "panel" }

// toggle-group
{ "id": "ctrl_source",
  "type": "toggle-group",
  "label": "Source",
  "attributeKey": "source",
  "default": "latest",
  "options": [
    { "value": "latest", "label": "Latest" },
    { "value": "manual", "label": "Pick" }
  ],
  "parentPanelId": "panel" }

Consume

JSX

JSX
export default function Collection({ attributes }) {
  const source = attributes.source === 'manual' ? 'manual' : 'latest';
  // ... branch on `source`
}

PHP

PHP
<?php
$source = ($attributes['source'] ?? 'latest') === 'manual' ? 'manual' : 'latest';
// ... branch on $source

Every field also takes the keys common to all fields.

Built from GCB Lite 0.4.0 (ce232d4). Source: schemas/controls/toggle.md.

Copyright © 2026 Runchain. WordPress is a trademark of the WordPress Foundation.