Skip to content

ColorPalette: Allow inline editing for colors - #79266

Open
juanfra wants to merge 36 commits into
trunkfrom
try/color-palette-inline-editing
Open

juanfra wants to merge 36 commits into
trunkfrom
try/color-palette-inline-editing

Conversation

@juanfra

@juanfra juanfra commented Jun 17, 2026 •

Copy link
Copy Markdown
Member

What?

🔗 link to test in playground

Adds inline color-palette editing to the block inspector's color picker. While editing a page/post you can now manage palette colors directly from the color control instead of switching to global styles. There a different capabilities depending on the palette:

  • Custom colors: Allows to add, rename, change color, and delete.
  • Theme / default colors: recolor only (allows only value editing. Names/slugs stay fixed, matching what GS allows today).

All edits persist to the user's global styles entity with optimistic updates and snackbar feedback, and preview live on the canvas as you drag.

In terms of UX, after trying a few different directions I found that the way it could work best would be by not moving too far from the design language we have now for the palette and adding a few buttons and states.

Regarding implementation, the direction I took was to have this behind a private prop (as we have some other preceding examples).

The way it works is the following:

  • We're adding actions next to the color name (below the square that triggers the picker). We have Edit/Delete and when clicked, the area transforms into a form. Once you open the color picker it will edit the color value, and there's also an input to change the name (if it is a custom color, not available for theme or core colors). Hitting save will save the changes and will trigger a snackbar so that we can give immediate feedback
  • Saving new custom colors: Once you pick a color that's not part of any palette, next to the color name there'll be a "+" button to save it. Clicking that button will open the form, so that you can set the color name and adjust the color if necessary. There's also a round + button in the Custom color palette so you can add them from there. These two affordances are there, because the latter may not be reachable depending of the context (if there are too many custom colors, or if the popover is opened in a way that's trimming some content and only showing the top)

A few notes:

  • Sorry for the size of the PR, but it was really difficult to decouple things.
  • Included a fix for bug I've found with the color picker when the colors were changing fast. It became noticeable while debugging in Firefox. I've commited that separately in case we want to take it out of the PR and take care of it independently. Took this out since Fix Color Picker Cursor Shaking Issue #80205 was merged.
  • There's an issue (preceding these changes) when changing custom color names, the value is lost. It was reported here, and maybe having the inline editing is exposing it more. We should try to fix that one.
  • Color previewing is applied as a single css variable style override on the canvas, not as a global-styles entity edit per pointer move. This avoids re-merging the config, regenerating
    the full block stylesheet.
  • Also updated the contrast checker. It now subscribes to style overrides, so its warning updates during preview for saved colors.
  • Added a small local setImmutably copy in @wordpress/editor because no package exports a public one (block-editor and global-styles-engine both keep theirs internal)

Why?

Managing colors when editing content was really a pain. If you are testing out colors for the website you are building you want to be able to save them to your palette in the same context, without the need to go to global styles or writing an hex code to later save in a different screen.

The idea was to have this only for custom colors. While demoing it to @Mamaduka and @richtabor at WCEU they suggested that it'd be also interesting to have this same functionality for theme colors.

How?

ColorPalette receives an editing config keyed by each palette slug:

capability operations
full add / rename / recolor / delete (custom)
value recolor only (theme, default)

When there's no value (slug), then it's read only.

Per the repo's guidance, the editing config is passed via a private prop (the same pattern as globalStylesDataKey, etc)
obtained through unlock(). It does not appear in the public props type.

if the capabilities are there, then the palette will show up different UIs for the different use cases.

Testing Instructions

  1. Open a post or page.
  2. Select a block
  3. Try changing the background color.
  4. Confirm that you are able to modify any theme color.
  5. Confirm you're able to create/update/delete custom colors.

Testing Instructions for Keyboard

Screenshots or screencast

color-palette-inline-editing.mp4

Use of AI Tools

Cursor/Claude

@juanfra
juanfra requested review from a team and ajitbohra as code owners June 17, 2026 10:22
@juanfra juanfra added the [Type] Enhancement A suggestion for improvement. label Jun 17, 2026
@juanfra juanfra added Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Feature] Colors Color management labels Jun 17, 2026
@juanfra
juanfra requested review from a team and Mamaduka and removed request for a team, ajitbohra, ellatrix and tellthemachines June 17, 2026 10:22
@github-actions github-actions Bot added [Package] Components /packages/components [Package] Editor /packages/editor [Package] Block editor /packages/block-editor labels Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@github-actions

github-actions Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Size Change: +10.5 kB (+0.14%)

Total Size: 7.66 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 435 kB +355 B (+0.08%)
build/scripts/components/index.min.js 287 kB +8.34 kB (+3%)
build/scripts/editor/index.min.js 510 kB +1.14 kB (+0.22%)
build/styles/components/style-rtl.css 18.2 kB +173 B (+0.96%)
build/styles/components/style-rtl.min.css 15.1 kB +157 B (+1.05%)
build/styles/components/style.css 18.3 kB +173 B (+0.96%)
build/styles/components/style.min.css 15.1 kB +157 B (+1.05%)

compressed-size-action

@github-actions

github-actions Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Flaky tests detected in 71aa610.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29251187430
📝 Reported issues:

@aduth

aduth commented Jun 17, 2026

Copy link
Copy Markdown
Member

Watching the video, I wonder about the accessibility of the proposed experience and particularly the focus order and focus shifting. It looks like clicking the "Add" button at the bottom of the panel shifts focus back up to the input field for the name, but it's placed after the field that the user is expected to interact with to choose the color. So the process of adding a color involves moving focus backwards, and the user being aware that they have to then select a value in a preceding field (which may not be obvious to screen reader users, for example).

I wonder if this should be more like how the custom color selector works in the Site Editor, which is still "inline". And we'd have the benefit of reusing existing components and user familiarity.

image

Alternatively, if that's not workable, could we have it as a separate dialog triggered from the "+" button, or at least a link to the global styles settings?

@juanfra

juanfra commented Jun 18, 2026 •

Copy link
Copy Markdown
Member Author

Thanks for looking into this @aduth! Fair point about the focus order.

The idea of the editing zone is to keep the user in the same color picking flow with a familiar UI, instead of the friction of sending them somewhere else to manage colors and come back. On close (save or cancel) focus returns to where it was.

You're right that for SR users the order of landing on the name field can be confusing, especially when no color is chosen yet. I'll iterate on that and adjust the focus for these cases.

Regarding reusing the PaletteEdit: I personally don't think it fits here. In a popover it doesn't scale. The list of custom colors pushes the rest down, and the experience can be quite messy if there are quite some colors. It also adds a second way to pick colors (the circle options, which are a way to "select" a pre-saved color in that context) next to the square swatch on top, which is more confusing than familiar in this context.

@github-actions github-actions Bot added [Package] Boot /packages/boot [Package] Admin UI /packages/admin-ui [Package] Abilities /packages/abilities [Package] Design System MCP /packages/design-system-mcp labels Sep 6, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@juanfra
juanfra force-pushed the try/color-palette-inline-editing branch from 8dc3737 to ab91d9a Compare September 6, 2026 16:47
@github-actions github-actions Bot removed [Package] Date /packages/date [Package] Data /packages/data [Package] A11y /packages/a11y [Package] Autop /packages/autop [Tool] Babel preset /packages/babel-preset-default [Tool] Browserslist config /packages/browserslist-config [Package] DOM ready /packages/dom-ready [Package] Deprecated packages/deprecated [Tool] Babel plugin makepot /packages/babel-plugin-makepot labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: +7.17 kB (+0.09%)

Total Size: 8.01 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 480 kB +464 B (+0.1%)
build/scripts/components/index.min.js 272 kB +5.11 kB (+1.91%)
build/scripts/editor/index.min.js 585 kB +1.05 kB (+0.18%)
build/styles/components/style-rtl.css 16.2 kB +131 B (+0.81%)
build/styles/components/style-rtl.min.css 13.8 kB +140 B (+1.03%)
build/styles/components/style.css 16.3 kB +133 B (+0.82%)
build/styles/components/style.min.css 13.8 kB +138 B (+1.01%)

524b96d Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric f40baee trunk % Change
timeToFirstByte 58.7 ms +12.61% -5.45% 63 ms +4.44% -11.83% -6.83%
largestContentfulPaint 98 ms +2.04% -10.2% 96 ms +0% -8.33% 2.08%
lcpMinusTtfb 33.8 ms +20.41% -3.85% 31.95 ms +4.23% -5.48% 5.79%
wpBeforeTemplate 28.21 ms +27.33% -1.6% 30.92 ms +13.68% -11.55% -8.76%
wpTemplate 24.69 ms +4.05% -3.28% 24.77 ms +3.43% -1.86% -0.32%
wpTotal 54.95 ms +11.26% -5.39% 58.91 ms +4.09% -11.9% -6.72%
wpMemoryUsage 7.52 MB +0% -0% 7.48 MB +0% -0% 0.46%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric f40baee trunk % Change
timeToFirstByte 43.95 ms +14.56% -2.16% 44.6 ms +15.13% -2.8% -1.46%
largestContentfulPaint 90 ms +11.11% -2.22% 88 ms +13.64% -0% 2.27%
lcpMinusTtfb 45.95 ms +5.44% -2.07% 45.3 ms +0.88% -1.88% 1.43%
wpBeforeTemplate 26.39 ms +16.64% -2.54% 26.15 ms +24.93% -2.6% 0.92%
wpTemplate 14.82 ms +9.04% -2.83% 14.75 ms +6.78% -2.37% 0.47%
wpTotal 40.98 ms +15.08% -2.05% 41.74 ms +14.49% -3.31% -1.82%
wpMemoryUsage 5.51 MB +0% -0% 5.47 MB +0% -0% 0.64%
wpDbQueries 14 +0% -0% 14 +0% -0% 0%

media-processing

Metric f40baee trunk % Change
mediaProcessingJpeg 403.07 ms +0.66% -1.51% 404.91 ms +0.74% -1.13% -0.45%
mediaProcessingAvif 6054.12 ms +0.37% -0.02% 6107.12 ms +0.45% -0.21% -0.87%
mediaProcessingJpegToAvif 4190.43 ms +0.12% -0.45% 4230.44 ms +0.22% -0.16% -0.95%

media-upload

Metric f40baee trunk % Change
jpegUploadProcessing 1414.14 ms +1.44% -0.8% 1441.56 ms +0.43% -0.99% -1.9%
pngUploadProcessing 213.52 ms +1.27% -1.94% 215.81 ms +1.55% -1.37% -1.06%
largeJpegUploadProcessing 1408.84 ms +0.78% -0.79% 1426.08 ms +0.57% -0.34% -1.21%
multipleImageUploadProcessing 1568.77 ms +0.28% -1.48% 1631.67 ms +0.96% -1.45% -3.85%

post-editor

Metric f40baee trunk % Change
serverResponse 511.87 ms +5.19% -4.13% 499.7 ms +4% -5.21% 2.44%
firstPaint 217.55 ms +18.23% -8.27% 252.42 ms +7.68% -32.49% -13.81%
domContentLoaded 1303.44 ms +1.21% -0.14% 1281.73 ms +1.22% -0.8% 1.69%
loaded 1304.93 ms +1.21% -0.14% 1283.05 ms +1.22% -0.8% 1.71%
firstContentfulPaint 430.88 ms +1.13% -1.7% 416.86 ms +1.3% -3.59% 3.36%
firstBlock 3621.87 ms +0.93% -0.85% 3585.45 ms +0.31% -0.5% 1.02%
type 15.06 ms +8.03% -9.3% 15.06 ms +3.05% -6.57% 0%
typeWithoutInspector 13.99 ms +9.22% -2.79% 14.09 ms +12.42% -2.98% -0.71%
typeWithTopToolbar 17.9 ms +2.79% -8.88% 18.91 ms +2.59% -6.19% -5.34%
typeContainer 9.32 ms +10.94% -6.55% 9.17 ms +9.27% -5.34% 1.64%
focus 74.76 ms +25.96% -4.47% 74.29 ms +13.6% -9.5% 0.63%
firstFocus 172.14 ms +0% -0% 177.76 ms +0% -0% -3.16%
selectAll 622.6 ms +3.4% -1.83% 610.02 ms +0.93% -0.41% 2.06%
listViewOpen 70.56 ms +14.78% -9.59% 70.79 ms +10.54% -10.35% -0.32%
inserterOpen 23.18 ms +1.98% -3.67% 22.7 ms +7.58% -0.66% 2.11%
inserterHover 3.34 ms +10.78% -8.68% 3.34 ms +13.47% -10.48% 0%
inserterSearch 8.28 ms +14.49% -12.68% 8.07 ms +7.81% -7.43% 2.6%
loadPatterns 623.5 ms +1.15% -1.59% 618.94 ms +1.49% -1.75% 0.74%
wpTotal 501.85 ms +4.9% -4.22% 489.68 ms +4.02% -5.31% 2.49%
wpMemoryUsage 13.05 MB +0% -0% 13.02 MB +0% -0% 0.28%
wpDbQueries 54 +0% -1.85% 54 +0% -1.85% 0%

site-editor

Metric f40baee trunk % Change
serverResponse 391.92 ms +5.1% -5.85% 412.61 ms +2.34% -2.3% -5.01%
firstPaint 209.63 ms +4.16% -5.7% 236.87 ms +20.81% -4.52% -11.5%
domContentLoaded 1355.67 ms +1.67% -0.91% 1344.78 ms +2.93% -0.59% 0.81%
loaded 1356.88 ms +1.65% -0.91% 1345.89 ms +2.94% -0.59% 0.82%
firstContentfulPaint 436.87 ms +0.94% -2.06% 423.57 ms +2.54% -3.03% 3.14%
firstBlock 4237.51 ms +0.54% -0.81% 4202.75 ms +0.39% -0.91% 0.83%
type 15.1 ms +2.72% -7.35% 15.01 ms +9.33% -8.86% 0.6%
navigate 104.73 ms +20.01% -2.01% 96.31 ms +7.41% -3.42% 8.74%
loadPatterns 1404.76 ms +11.36% -10.82% 1407.6 ms +6.04% -10.02% -0.2%
loadPages 1085.48 ms +3.37% -2.64% 1114.86 ms +4.09% -4.66% -2.64%
wpTotal 381.44 ms +5.27% -6.17% 401.14 ms +2.54% -2.17% -4.91%
wpMemoryUsage 12.06 MB +0% -0% 12.03 MB +0% -0% 0.3%
wpDbQueries 43 +2.33% -0% 43.5 +1.15% -1.15% -1.15%

524b96d Run

# Conflicts:
#	packages/block-editor/src/components/color-palette/test/__snapshots__/control.jsdom.test.jsx.snap
@juanfra

juanfra commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Fixed some merge conflicts. Sorry for the pings! A bad merge triggered requests to codeowners.

Taking the chance to ping @WordPress/gutenberg-design, would love to get some eyes on this if anyone has time for feedback.

@jasmussen

Copy link
Copy Markdown
Contributor

Thanks for the ping! Thanks for the work, for contributing. At a glance, this looks pretty cool, I notably like the circular plus button to add new "custom swatches".

For that reason I would say the blocker to this work isn't design, but to address the reasonable comments by Andrew, and then to connect with the fine folk interacting with #74930 who are solving a tangential issue. If you can thread the needle on both, this feels like a cool contribution.

@juanfra

juanfra commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Thanks @jasmussen! Happy to hear the direction feels right from a design perspective.

I've worked through the a11y feedback. Left a bit more context on this comment. Adding or editing a color now goes to the picker first instead of the name field. So the focus issue about moving backwards should be resolved. It also returns to the swatch after saving, cancelling, or deleting. The + tile is now a listbox option and the delete confirmation is announced.

@aduth, when you get a chance, I'd love to hear if this covers what you had in mind, or if there's anything else I should look at 🙏

I also left some feedback on #74930 (comment). Happy to keep iterating and see how we improve this area.

@t-hamano

t-hamano commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for working on this. This is just my opinion, but I am hesitant to implement this feature. This is because, internally, it means directly manipulating global styles through the block instance's toolbar.

What happens if that color palette is already applied to other blocks? If a user modifies or removes a custom color palette solely to color a specific block, it will affect all blocks and styles where that palette is applied. This, of course, also applies to global styles, but since the user is interacting with the block sidebar, they might not realize that the change will impact the entire site.

I would like to hear your thoughts on this concern.

@juanfra

juanfra commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Thanks Aki! that's a fair thing to raise.

I believe that's kind of the point, though. Not being able to manage colors without leaving the creation flow is exactly what this is trying to fix. From the feedback I gathered it's a real blocker when building a site and kind of the expectation of many builders (heard the same for typography).

A few guardrails can be that picking a color still works the same way, clicking a swatch still only sets the block attribute. Editing is a separate action (intentional) behind the pencil, with a form and an explicit save. The colors are grouped and named, so you can see that you're touching something that's part of a palette. And it's meant to only show up for people who can already edit global styles.

Having said this, you're right that there's no communication that the change applies everywhere. I see that as something fixable, maybe communicating in the form and/or snackbar?

@jasmussen

Copy link
Copy Markdown
Contributor

Good concerns, good instincts. I don't have a strong opinion leaning in either one direction or the other, so to help facilitate a path forward, I'd rather connect some dots.

In the Advanced panel, we have a "Push to global styles" button, which converts any local styles to global. While that is precedence for allowing the editing of global styles locally, it does validate Akis point, as I've heard lots of feedback by wp.com users who were confused about this button, notably before it had a confirm dialog which was added for the same reason. In that sense, if we do go with something that creates global changes, it seems like we should at least invoke the same modal dialog that this button invokes.

Separately, @fcoveram has carefully explored how to improve style inheritance visualisation. The latest direction I've chatted with him about involves an ellipsis menu somewhere in the inspector: shows style inheritance information, and features buttons to reset to inherited styles and potentially also the same push to global styles, just moved to that menu. In the latter case, the modal would continue to be part of it, and all this is mostly conceptual at this point.

Is that helpful?

This branch has not been deployed

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

Labels

[Feature] Colors Color management Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Package] Block editor /packages/block-editor [Package] Components /packages/components [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants