Editor: Add a background clip block support to facilitate text gradients - #13491
Open
aaronrobertshaw wants to merge 1 commit into
Open
Editor: Add a background clip block support to facilitate text gradients#13491aaronrobertshaw wants to merge 1 commit into
aaronrobertshaw wants to merge 1 commit into
Conversation
Adds a background.backgroundClip block support, so a block can set which box its background is painted into: border-box, padding-box, content-box, or the text itself. Clipping to the text is what gives blocks a gradient text fill. Registers the property in the style engine and theme.json, allows the declarations through KSES, and skips the has-background class when the background is clipped to the text. Props aaronrobertshaw. See #66094.
aaronrobertshaw
requested review from
andrewserong,
ramonjd,
talldan and
tellthemachines
September 11, 2026 09:41
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
61 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of Gutenberg PR WordPress/gutenberg#77141
Trac ticket: https://core.trac.wordpress.org/ticket/66094
Adds a
background.backgroundClipblock support, so a block can set which box its background is painted into:border-box,padding-box,content-box, or the text itself. Clipping to the text is what gives blocks a gradient text fill.This PR backports:
backgroundClipdefinition and its value parser inWP_Style_Engine,classnames_funccallback there, which keeps the file in sync with Gutenberg. Behaviour is unchanged,background.backgroundClipsetting and style inWP_Theme_JSON, its CSS property mapping, and the vendor prefixed declarations that go with it,background-clipand its vendor prefixed companions added to the KSES safe style allowlist,has-backgroundclass being skipped when the background is clipped to the text,For the
textvalue the engine also emits-webkit-background-clipand-webkit-text-fill-color. For the box values only the fill color is reset, because-webkit-background-clipis an alias ofbackground-clipin Chromium and resetting it would discard the value set above.The editor controls, and the
core/headingandcore/paragraphopt-ins, arrive with the next Gutenberg package update.Testing instructions
No block opts in yet and there is no control in the editor, so test the generated global styles.
theme.json:Without the change neither
background-clipdeclaration is generated, so both render as a plain background gradient filling the whole block.Use of AI
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: the mechanical port and polishing this description