Skip to content

Bug when using only custom spacing sizes and setting spacingScale.steps to 0 #70446

@tomdevisser

Description

@tomdevisser

Description

When configuring a theme to use only custom spacing sizes in theme.json, I ran into issues with the spacingScale setting.

If I set settings.spacing.spacingScale.steps to 0, the JSON schema throws an error:

“Value is below the minimum of 1.”

However, if I set it to 5 (to match the number of custom spacingSizes I’ve defined), the UI unexpectedly shows the default spacing sizes — even though I’ve explicitly set "defaultSpacingSizes": false.

This seems to expose two bugs:

  1. There’s no valid way to fully disable the internal spacing scale when using only custom sizes.
  2. The default scale is applied even when it’s explicitly turned off, depending on the steps value.

Step-by-step reproduction instructions

  1. Create a block theme using schema version 3.
  2. In theme.json, configure spacing settings as follows:
"spacing": {
  "defaultSpacingSizes": false,
  "blockGap": true,
  "customSpacingSize": false,
  "margin": true,
  "padding": true,
  "spacingScale": {
    "steps": 5
  },
  "spacingSizes": [
    { "name": "Extra Small - 0.5rem", "size": "0.5rem", "slug": "xs" },
    { "name": "Small - 1rem", "size": "1rem", "slug": "sm" },
    { "name": "Medium - 1.5rem", "size": "1.5rem", "slug": "md" },
    { "name": "Large - 2.5rem", "size": "2.5rem", "slug": "lg" },
    { "name": "Extra Large - 3rem", "size": "3rem", "slug": "xl" }
  ],
  "units": ["rem"]
}
  1. Observe that the spacing UI includes default spacing sizes, even though they were explicitly disabled.
  2. Try setting steps to 0 to remove the default scale — the schema rejects it as invalid.

Screenshots, screen recording, code snippet

Image Image

Environment info

  • LocalWP setup
  • PHP 8.2.27
  • WordPress 6.8.1
  • No plugins installed
  • Browser: Brave v1.79.123

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] LayoutLayout block support, its UI controls, and style output.[Type] EnhancementA suggestion for improvement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions