Skip to content

Schema: theme.json allows to set styles.blocks.*.spacing.blockGap #38929

Closed

Description

@ocean90

Description

I was trying to set a default block gap styling via theme.json but that didn't work.

Example:

{
	"$schema": "https://schemas.wp.org/wp/5.9/theme.json",
	"version": 2,
	"styles": {
		"spacing": {
			"blockGap": "20px"
		},
		"blocks": {
			"core/navigation": {
				"spacing": {
					"blockGap": "8px"
				}
			}
		}
	}
}

Turns out that this isn't supported. Another related comment: #37360 (comment)

It would be nice if the schema could be adjusted to show an error if the blockGap property is set for block styles.

Step-by-step reproduction instructions

  1. Extend the theme.json from Twenty-Twenty Two with the example from above
  2. Notice that the block gap is not used, neither in the settings panel nor in the CSS output on frontend.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

Activity

  1. added
    [Type] Bug
    Developer Experience
    on Feb 19, 2022
  2. mrleemon commented on Feb 21, 2022

    @mrleemon
    Contributor

    So, one cannot set a blockGap value in the styles section if blockGap is not enabled in the settings section? A theme developer would want to set a default blockGap but not let theme users change it.

  3. skorasaurus commented on Mar 2, 2023

    @skorasaurus
    Member

    So, one cannot set a blockGap value in the styles section if blockGap is not enabled in the settings section? A theme developer would want to set a default blockGap but not let theme users change it.

    UPDATE:

    You can set a BlockGap value but prevent theme users from changing it by following this example:
    but instead
    set the blockGap value to false;

  4. skorasaurus commented on Mar 6, 2023

    @skorasaurus
    Member

    Since this issue was made; blockGap on a per block basis was implemented In #40875

    If you're having specific issue with the navigation block; please create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Developer Experience[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions