Skip to content

Registering block styles via JSON no longer works without extra styles #72854

@coreyworrell

Description

@coreyworrell

Description

JSON files in theme styles folder used to register if you only had a title and slug property (along with blockTypes), this would add the CSS class to the block and allow you to style externally or hook into with JavaScript, etc.

Now it seems those files are ignored unless you specify an external stylesheet in the JSON or you use some kind of style in the schema.

Step-by-step reproduction instructions

  1. Create theme/styles/blocks/gallery-1.json
    {
      "$schema": "https://schemas.wp.org/trunk/theme.json",
      "version": 3,
      "title": "Slideshow",
      "slug": "slider",
      "blockTypes": [
        "core/gallery"
      ]
    }
  2. Load admin, insert Gallery block, notice there is no style option for "Slideshow"
  3. Add styles to JSON
    "styles": {
      "spacing": {
        "padding": {
          "top": "0"
        }
      }
    }
  4. Reload admin, you'll see "Slideshow" as option for style

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.8.3

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

    [Feature] Theme Style VariationsRelated to style variations provided by block themes[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions