Skip to content
JS Filters

lzb.constructor.controls.item-attributes

Filters the DOM props of a control card in the block builder controls list. Use it to add a class or a data attribute to the card so your own stylesheet or script can find that control.

Attributes

NameTypeDescription
controlsItemAttributesObjectprops spread onto the card <div>
propsObjectaddControl, removeControl, updateData, printControls, data, id, controls

The default object has eight keys:

NameTypeDescription
classNameStringlzb-block-builder-controls-item plus the undefined, selected and dragging modifiers
onClickFunctionselects the control, which is what opens its settings sidebar
roleStringnone
data-control-typeStringcontrol type, for example text
data-control-nameStringcontrol name as entered in the builder
data-control-labelStringcontrol type again, the same value as data-control-type
refFunctiondnd-kit node ref that makes the card sortable
styleObjectdrag transform and transition

props.data holds the settings of this control, props.id its uid, and props.controls every control on the block keyed by uid.

Additional Filters

NameDescription
lzb.constructor.controls.CONTROL_TYPE.item-attributesspecific controls only

The type-specific filter runs first and the generic one receives its result, so a handler on lzb.constructor.controls.item-attributes can overwrite what a type-specific handler set.

Usage

JS
wp.hooks.addFilter(
  "lzb.constructor.controls.item-attributes",
  "my.custom.namespace",
  function (attributes, props) {
    if (props.data.save_in_meta !== "true") {
      return attributes;
    }
 
    return {
      ...attributes,
      className: `${attributes.className} my-meta-control`,
      "data-meta-name": props.data.save_in_meta_name || props.data.name,
    };
  },
);

Spread the incoming object instead of building a new one. Dropping ref detaches the card from dnd-kit and the control can no longer be dragged into a new position, and dropping onClick makes the control unselectable so its settings never open. To change the rendered card rather than its props, use lzb.constructor.controls.item, which filters the finished element.

Was this article helpful?

Copyright © 2026 Lazy Blocks.