Fields

Checkboxes

Checkboxes is the multi-select choice field for a group of options.

Use this page to preserve the required attributes, empty-value handling, and option markup used by the checkbox-radio module.

Preview

Attributes

Checkbox groups depend on these structural attributes:

Field

AttributePurposeImportance
data-formie-field-handleStable field identity used by validation, conditions, and error renderingRequired
data-formie-max-optionsMax-selection enforcementOptional

Field layout

AttributePurposeImportance
data-formie-checkboxes-field-layoutGroup selector used by the checkbox-radio moduleRequired for checkbox behavior

Hidden input

AttributePurposeImportance
name fallback inputEnsures the field still submits when nothing is checkedRecommended

Field options

AttributePurposeImportance
data-formie-checkboxes-optionsOption-group wrapperRequired for checkbox behavior

Field input

AttributePurposeImportance
data-formie-checkbox-inputCheckbox selector used by FormieRequired for checkbox behavior
data-formie-input-idStable option identityRecommended
data-checkbox-toggleOptional "toggle all" checkbox hookPreserve when using the built-in toggle option

Styling classes

These classes are for presentation only. They are not behavior requirements:

Field layout

ClassDescription
formie-checkboxes-field-layoutCheckbox group layout styling class
formie-checkboxes-field-labelCheckbox group label styling class

Field options

ClassDescription
formie-field-optionsShared option-group styling
formie-checkboxes-optionsCheckbox group options styling class
formie-field-optionShared option wrapper styling
formie-checkbox-optionCheckbox option wrapper styling class

Field input

ClassDescription
formie-inputShared checkbox styling and focus treatment
formie-checkbox-inputCheckbox input styling class
formie-input-errorError-state styling class

Field option label

ClassDescription
formie-field-option-labelShared option label styling
formie-checkbox-option-labelCheckbox option label styling class

Behavior

The checkbox-radio module keeps checkbox fields aligned with Formie semantics by:

  • synchronizing DOM checked attributes with live state
  • treating required checkboxes as one logical group instead of per-input native validation
  • enforcing data-formie-max-options by disabling only unchecked options after the limit is reached

Events

Checkbox fields use the shared checkbox-radio field events described on JavaScript events.

The formie:field:checkbox-radio:init event

Triggered after the checkbox group has been wired and max-option or required behavior is active.

js
document.addEventListener('formie:field:checkbox-radio:init', (event) => {
  const { checkboxRadio } = event.detail;

  // Only target the services field.
  if (checkboxRadio?.dataset.formieFieldHandle !== 'services') {
    return;
  }

  // Mark the group so custom UI can react once behavior is ready.
  checkboxRadio.setAttribute('data-checkboxes-ready', 'true');
});
Last updated: May 6, 2026, 3:46 PM