💡 云策文档标注

概述

settings.dimensions 属性用于控制主题中区块的全局尺寸设置,决定用户界面中可用的尺寸控件。本文档介绍其用途和配置方法。

关键要点

  • dimensions 是 theme.json 中 settings 下的一个对象,目前仅支持 minHeight 属性。
  • minHeight 为布尔值,用于启用或禁用区块的最小高度控件。
  • WordPress 6.3 中,仅 Group 和 Post Content 核心区块支持此功能。

代码示例

{
  "version": 2,
  "settings": {
    "dimensions": {
      "minHeight": true
    }
  }
}

📄 原文内容

The settings.dimensions property in theme.json gives you control over the global dimensions settings for blocks. This property lets you decide which dimension controls are available in the user interface.

In this document, you will learn what the dimensions property is for and how you can use it in your theme.

Dimensions settings

dimensions is an object that’s nested directly within the top-level settings property in theme.json. Currently, it only lets you set a single property: 

  • minHeight: A boolean value for enabling block support for the Minimum Height control.

Take a look at the dimensions property in the context of a theme.json file with its default values:

{
	"version": 2,
	"settings": {
		"dimensions": {
			"minHeight": false
		}
	}
}

Minimum Height

The settings.dimensions.minHeight property lets you control whether the Minimum Height field appears for blocks that have opted into support for the feature. As of WordPress 6.3, the only core WordPress blocks that do are Group and Post Content.

To enable support for the control, you must set the property’s value to true in theme.json:

{
	"version": 2,
	"settings": {
		"dimensions": {
			"minHeight": true
		}
	}
}

This will enable the control in the interface. As shown in this screenshot, the Minimum Height field appears for the Group block (Stack variation):

WordPress post editor with a Stack block in the content canvas. Its minimum height is set in the sidebar.