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
| Prop | Type | Default | Description |
|---|---|---|---|
breakpoint | string | (required) | The responsive breakpoint: base, mobile, tablet, or wide |
attributes | object | (required) | The block’s full attributes object |
setAttributes | function | (required) | WordPress setAttributes function |
include | string[] | ['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 supportingpx,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
includecontains'mhGroup'andbreakpoint === '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
falseexplicitly, so a breakpoint can undo the base - CSS:
trueemitsheight: 0; overflow: visible;falseon a non-base breakpoint whose base istrueemitsheight: 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 / Ythrough theaspectRatioDimensionCSS-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
mhkey - resetAll: Removes
width,minWidth,height,minHeight, andmhfrom the breakpoint
Usage by Blocks
| Block | Include | Notes |
|---|---|---|
| Section | height, minHeight, mhGroup | All breakpoints for height/minHeight; base only for mhGroup |
| Container | height, minHeight, width, minWidth, mhGroup, aspectRatio | All breakpoints; base only for mhGroup |
| Fitted Image | zeroHeight | All breakpoints |
| Mapbox Map | height, minHeight, aspectRatio | All breakpoints; new blocks start at height: 400px |