Skip to content

Block Supports: Add background gradient support that can combine with background image#11384

Open
aaronrobertshaw wants to merge 2 commits intoWordPress:trunkfrom
aaronrobertshaw:add/background-gradient-support
Open

Block Supports: Add background gradient support that can combine with background image#11384
aaronrobertshaw wants to merge 2 commits intoWordPress:trunkfrom
aaronrobertshaw:add/background-gradient-support

Conversation

@aaronrobertshaw
Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/64974

This PR brings the PHP changes from the following Gutenberg PR to core:

WordPress/gutenberg#72628

Description

Adds background.gradient as a new block support, enabling blocks to combine a background gradient with a background image via comma-separated
background-image CSS values (e.g., background-image: linear-gradient(...), url(...)).

Currently, the only way to apply a gradient is through color.gradient, which renders as a background CSS shorthand and conflicts with background image
properties. By introducing background.gradient (stored at style.background.gradient), gradients become part of the background style group, allowing the
style engine to combine gradient and image values without conflict.

See: WordPress/gutenberg#32787

Testing

  1. Ensure PHP unit tests pass: npm run test:php -- --filter="Tests_Block_Supports_WpRenderBackgroundSupport|Tests_Block_Supports_Colors|Tests_wpStyleEngine|test_get_background_gradient|test_remove_insecure_p roperties_allows_combined|test_remove_insecure_properties_allows_background_gradient|test_get_settings_appearance_true"
  2. In a theme.json file, define a background gradient for the Group block using the new styles.blocks.core/group.background.gradient property (e.g.,
    "gradient": "linear-gradient(135deg, #000 0%, #fff 100%)"). Verify the gradient renders correctly on the frontend.
  3. Also set a backgroundImage on the same Group block and confirm both values combine into a single background-image CSS declaration.
  4. Verify existing style.color.gradient support continues to work on blocks that don't opt into background.gradient.
  5. On a block that supports both, set both style.color.gradient and style.background.gradient — confirm background.gradient takes precedence and the
    color.gradient shorthand is suppressed.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 28, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @1178653+wordpress-develop-pr-bot[bot]@users.noreply.github.com.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props aaronrobertshaw.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant