Opened 4 weeks ago
Last modified 16 hours ago
#66094 new enhancement
Editor: Add a background clip block support to facilitate text gradients
| Reported by: | aaronrobertshaw | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Editor | Version: | trunk |
| Severity: | normal | Keywords: | gutenberg-merge has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Backport of Gutenberg PR https://github.com/WordPress/gutenberg/pull/77141.
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, since CSS has no gradient colour.
For the text value the style engine also emits -webkit-background-clip and
-webkit-text-fill-color, and the block skips the has-background class because
nothing paints the block's background. For the box values only the fill colour
is reset, because -webkit-background-clip is an alias of background-clip in
Chromium and resetting it would discard the value.
The setting is not part of appearance tools. A theme opts in by setting
settings.background.backgroundClip, either true or an array of the values it
wants to offer.
The editor controls and the core/heading and core/paragraph opt-ins arrive with
the next Gutenberg package update.
Change History (3)
This ticket was mentioned in PR #13491 on WordPress/wordpress-develop by @aaronrobertshaw.
4 weeks ago
#1
- Keywords has-patch has-unit-tests added
@aaronrobertshaw commented on PR #13491:
2 weeks ago
#2
FYI, things are evolving on the Gutenberg PR this backports. I'll mark this as in draft until that stabilizes.
@peterwilsoncc commented on PR #13491:
16 hours ago
#3
@aaronrobertshaw Is this ready for review now that https://github.com/WordPress/gutenberg/pull/77141 has merged?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Backport of Gutenberg PR https://github.com/WordPress/gutenberg/pull/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:"styles": { "blocks": { "core/heading": { "background": { "gradient": "linear-gradient(to right,#ff0000,#0000ff)", "backgroundClip": "text" } }, "core/group": { "background": { "gradient": "linear-gradient(to right,#ff0000,#0000ff)", "backgroundClip": "content-box" } } } }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