Skip to content
  1. Extras
  2. PageBuilder
  3. Field types
  4. Free
  5. toggle

Field toggle ​

Version: Free.

Why this type ​

An on/off switch, without radio buttons or a checkbox. The data is yes or no, the same as yesno. It fits a mode that editors switch often.

When to use ​

  • Enable overlay, autoplay, section dark mode
  • showWhen on a neighbor boolean
  • Quick flag without "Yes/No" copy

Tips ​

Classic MODX yes/no use yesno. Value is still boolean, not a string.

Similar types ​

  • yesno for familiar yes/no
  • checkbox when the option needs an explicit label

Schema ​

json
{
  "name": "enabled",
  "type": "toggle",
  "label": "Enabled",
  "tab": "Content",
  "width": 100,
  "active": true
}

Value ​

Boolean.

Section data ​

Key enabled in the section data:

json
{
  "enabled": true
}

Chunk example ​

modx
<div class="block is-enabled">…</div>
fenom
{if $enabled}<div class="block is-enabled">…</div>{/if}

Common properties ​

For fields with name that are stored in the section data:

KeyTypeRoleCMP
tabstringGroup subtitle in the inspectoryes
width25–100Field width as % of the row (flex)yes
descriptionstringHint under the labelyes
defaultanyInitial value for a new sectionyes
activeboolfalse hides the field in the inspectoryes
requiredboolRequired on publish (draft still saves)yes

See fields overview.

See also ​