MethodDimensionControls

 
 
 
 

Overview

Width, height, min‑width, min‑height, and MatchHeight group controls for block sizing.

  • File: lib/blocks/components/MethodDimensionControls.js
  • Panel label: “Dimensions”

Props

PropTypeDefaultDescription
breakpointstring(required)The responsive breakpoint: base, mobile, tablet, or wide
attributesobject(required)The block’s full attributes object
setAttributesfunction(required)WordPress setAttributes function
includestring[]['width', 'minWidth', 'height', 'minHeight', 'mhGroup'] (also zeroHeight, aspectRatio, opt-in)Which controls to render

Controls

Width / Min Width / Height / Min Height

  • UI: UnitControl — WordPress’s native unit-aware input supporting px, em, rem, %, vh, vw, etc.
  • Settings keys: responsiveSettings.{breakpoint}.width, minWidth, height, minHeight
  • Default value on select: '0px'

MethodStyleTag only outputs these CSS properties when the value does not start with '0', preventing zero values from overriding inherited sizing. Now that these controls are “opt-in”, this behavior may be revised in future releases.


MatchHeight Group

  • UI: TextControl (free text input).
  • Settings key: responsiveSettings.base.mh
  • Visibility: Only rendered when include contains 'mhGroup' and breakpoint === 'base'. Not available on responsive breakpoints.

MatchHeight groups allow multiple blocks to be height‑matched on the frontend using the jQuery MatchHeight library (included via Method’s inc/matchHeight dependency). Blocks sharing the same group string will be equalized in height.


Zero Height

  • Settings key: responsiveSettings.{breakpoint}.zeroHeight (boolean)
  • UI: ToolsPanel item “Zero Height” with a toggle; opted in but off stores false explicitly, so a breakpoint can undo the base
  • CSS: true emits height: 0; overflow: visible; false on a non-base breakpoint whose base is true emits height: unset; overflow: unset
  • For overlap layouts where a block should not contribute to document flow. Used by Fitted Image.

Aspect Ratio

  • Settings keys: responsiveSettings.{breakpoint}.aspectRatioX / aspectRatioY (numbers, default 1 / 1 on select)
  • UI: ToolsPanel item “Aspect Ratio” with two NumberControls (X and Y)
  • CSS: emitted as aspect-ratio: X / Y through the aspectRatioDimension CSS-map key
  • Used by Container (on .method-container-content) and Mapbox Map (on the wrapper).

ToolsPanel Behavior

  • Dimension controls onSelect: Initialize to '0px'
  • Dimension controls onDeselect: Remove the key entirely
  • MatchHeight onSelect: Initialize to empty string
  • MatchHeight onDeselect: Remove the mh key
  • resetAll: Removes width, minWidth, height, minHeight, and mh from the breakpoint

Usage by Blocks

BlockIncludeNotes
Sectionheight, minHeight, mhGroupAll breakpoints for height/minHeight; base only for mhGroup
Containerheight, minHeight, width, minWidth, mhGroup, aspectRatioAll breakpoints; base only for mhGroup
Fitted ImagezeroHeightAll breakpoints
Mapbox Mapheight, minHeight, aspectRatioAll breakpoints; new blocks start at height: 400px

Changelog

VersionDescription
2.0.0-alpha4Introduced (a09be88).
2.0.0-beta7Opt-in zeroHeight toggle, with the CSS on both sides; first used by Fitted Image (5afb83a).
2.0.0-beta8Aspect Ratio item (aspectRatioX / aspectRatioY), first used by Container (bd7d2f4).