Skip to content

Icons: Redraw 35 prominent icons to strokes, and maintain absolute stroke-width#78808

Open
jasmussen wants to merge 25 commits into
trunkfrom
update/redraw-34-icons-to-stroke-based
Open

Icons: Redraw 35 prominent icons to strokes, and maintain absolute stroke-width#78808
jasmussen wants to merge 25 commits into
trunkfrom
update/redraw-34-icons-to-stroke-based

Conversation

@jasmussen

@jasmussen jasmussen commented May 29, 2026

Copy link
Copy Markdown
Contributor

What?

Followup/replacement to #78774, which now includes the change including resilience for compatibility.

In this PR, I redrew/changed 34 icons to be stroke-based rather than purely fill-based. An existing icon was already stroke-based, square. This brings an enormous amount of flexibility as far as future animation and customisation properties, it simplifies the Figma to Icon flow, but notably it means that icons now maintain their stroke-width across sizes. Paragraph shown as example, 16, 24, 32px sizes:

Skærmbillede 2026-05-29 kl  12 25 11 Skærmbillede 2026-05-29 kl  12 25 17 Skærmbillede 2026-05-29 kl  12 25 42

Why?

For the majority of these icons, no visual change should be perceptible in where they are used today, because we use them mostly in their standard 24x24px sizes. And we do that specifically because of the shortcoming in how they scale, shifting stroke-width making them look out of place next to each other.

By enforcing a monoline stroke-width, icons can now be shown at virtually arbitrary sizes (though they can get fuzzy if shown really small), and yet still feel as if they belong together since their stroke-widths are maintained. A future perspective is even to allow consumers of the componentry to either animate the stroke, both the width and the dash-style, offering some interesting options, such as how this WordPress logo is animated.

How?

This PR includes both the tech to maintain a uniform stroke-width across icon dimensions, as well as 35 icons that take advantage of it. I am working in a WIP Figma file to go through all existing icons, as such:

Icons

In black, those are the icons in this PR, done/redrawn. In red, still todo. In blue, icons we will not be redrawing as they are not/can't be stroke-based. In gray, icons that need redesigns anyway. Once this effort is done, these icons will move to the main Figma design library. I believe there are some additional icons shipping in trunk that are not depicted in this list, but I will be sure to identify those once I'm through this effort.

Testing Instructions

Check out the PR; run npm run storybook:dev, go to Icons > Library, and then observe that at both 16, 24, and 32, that icons look as intended. These icons:

  • add-card
  • add-template
  • cancel-circle-filled
  • caution
  • caution-filled
  • code
  • comment-author-avatar
  • cover
  • currency-dollar
  • currency-euro
  • currency-pound
  • drafts
  • help
  • help-filled
  • image
  • info
  • lifesaver
  • link
  • link-off
  • navigation
  • not-allowed
  • paragraph
  • pending
  • plus-circle
  • plus-circle-filled
  • published
  • scheduled
  • site-logo
  • star-empty
  • star-filled
  • star-half
  • styles
  • square
  • time
  • tip

Use of AI Tools

Claude Code was used to extract a todo-list of icons for me, but the rest is hand-rolled, human spirit work.

@jasmussen jasmussen requested review from a team and t-hamano May 29, 2026 10:35
@jasmussen jasmussen self-assigned this May 29, 2026
@jasmussen jasmussen added [Type] Enhancement A suggestion for improvement. [Package] Icons /packages/icons [Feature] Icons Related to Icon registration API and Icon REST API labels May 29, 2026
@jasmussen jasmussen marked this pull request as ready for review May 29, 2026 10:35
@github-actions

github-actions Bot commented May 29, 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: jasmussen <joen@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: fcoveram <fcoveram@git.wordpress.org>

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

@jasmussen

Copy link
Copy Markdown
Contributor Author

A note that I forgot to mention: as I carefully hand-redraw these, some curves and vectors become more precisely positioned, clearly mistakes from previous iteration. In 95% of the cases in this batch, the end result when seen at 24x24 is invisible. However I want to point out a couple of icons were very slightly visually refreshed as part of this, in case that invites feedback. IMO, it's not enough to warrant a changelog entry beyond what this PR can benefit from regardless, but for your awareness:

  • time-to-read has changed from using sharp hands to using the same style as that of the "pending" clock
  • the stars (star-empty, star-half, star-filled) now have fully sharp corners instead of barely perceptibly visible rounded corners. This was necessary to convert it to strokes.

@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

Flaky tests detected in 932fcc0.
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/27810898468
📝 Reported issues:

@jameskoster

Copy link
Copy Markdown
Contributor

Wonderful!

Since this involves redrawing icons, would it make sense to address some of the low-hanging fruit in #65786 as well? For instance applying endcap-roundness consistently, pixel grid alignment, and footprint consistency?

@jasmussen

Copy link
Copy Markdown
Contributor Author

Yes it does indeed! And notably the pixel grid alignment I've been fixing here. There's been a lot discovered. I've also unified a couple of circles that were off-size.

I'm hesitant to do too much, but would be happy to follow up after we land a good new stroke based baseline. One really potent improvement as I do this: the new icons are subtantially easier to edit and work with, because what we used to call the "icon source", the stroke based version we would go ahead and convert to fills, that is now the icon that we ship, one and the same, so the Figma to GitHub flow is now very much improved.

The short is, once this is done, it should be both easier to contribute, to edit, to consolidate, and all that.

@jameskoster

Copy link
Copy Markdown
Contributor

Yes, appreciate it's a balance; we want to avoid scope creep. I'm just aware that it might be easier to tweak these things in one go rather than sequentially, with no meaningful trade-offs that I can think of.

One other thing that springs to mind from a previous exploration around converting the icons to be stroke-based... there is quite a bit of css in Gutenberg that targets icons with fill styles. This can have a very different effect when the icons are outlined. We might need to swap some of those fill styles to use stroke instead. Probably worth smoke testing.

@jasmussen jasmussen requested review from a team and ajitbohra as code owners May 29, 2026 13:42
@github-actions github-actions Bot added [Package] Components /packages/components [Package] Edit Site /packages/edit-site labels May 29, 2026
@jasmussen jasmussen force-pushed the update/redraw-34-icons-to-stroke-based branch from d336873 to 9c97f83 Compare May 29, 2026 13:42
@jasmussen

jasmussen commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

It's funny you should mention that, because in testing other things, I found issues with exactly that:

Skærmbillede 2026-05-29 kl  15 32 20

This is now fixed, but I will write some additional detail on the fix in context of the code.

image


svg,
path {
svg {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was necessary because without it, everything gets a fill, including what is meant to just be a stroke based circle (with a hole in the middle).

I prefer to keep PRs minimal, but this one was necessary in order for this PR to be possible to land. I have some additional changes I want to push—a normalisation script and some more resilience, but this was a minimal change I was able to do. I wasn't able to find any ill consequences from this change, but CC'ing some component experts for a gut check: @mirka @ciampo

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work well

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust @ciampo's judgment here but just wanted to confirm that this has been tested and verified to not cause any unexpected consequences.

@ciampo ciampo Jun 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To expand a bit:

All in-repo usage shouldn't be affected, because @wordpress/icons icons are either:

  • Single filled path (with no associated fill rule), where the child path will nherit the fill rule from the parent svg anyway;
  • Stroke-based with explicit fill: none as an inline style, which takes precedence

I scanned the codebase for all usages of ItemGroup Item + SVGs and all first-party usage should be good (still better to run smoke tests, though).

The risk for visual regressions exists but is limited to third-party usage, in case the third-party icon relied on that path { fill: currentColor } rule that is being removed here. In particular, I believe the main sources where this regression could manifest are:

  • The block list in the Global Styles screen (for third party blocks);
  • The sidebar navigation of the recently added boot package, for consumer-registered icons

I think we should be good with a CHANGELOG entry. The regression in this case will be purely visual and won't prevent users from interacting with the Gutenberg app.

<HStack justify="flex-start">
{ icon && (
<Icon
style={ { fill: 'currentcolor' } }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule overrode the SVG that was inserted, and forced a fill rule on it, making it impossible to use stroke-based icons.

Comment thread packages/icons/lib/generate-library.cjs Outdated
return `${ camelKey }: '${ value }'`;
} )
.join( ', ' );
return ` style={ { ${ declarations } } }`;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was required so the inline style="fill: none" on stroke icons gets translated to React's object form during build. Without it, React ignores the style and the icons render filled.

Claude Code helped me with this, btw.

@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

Size Change: +1.91 kB (+0.02%)

Total Size: 8.6 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 52.9 kB +18 B (+0.03%)
build/modules/content-types/index.min.js 159 kB +101 B (+0.06%)
build/modules/edit-site-init/index.min.js 1.48 kB +83 B (+5.93%) 🔍
build/modules/workflow/index.min.js 19.9 kB +14 B (+0.07%)
build/scripts/block-directory/index.min.js 43.6 kB -92 B (-0.21%)
build/scripts/block-editor/index.min.js 380 kB +129 B (+0.03%)
build/scripts/block-library/index.min.js 324 kB +11 B (0%)
build/scripts/commands/index.min.js 21 kB +11 B (+0.05%)
build/scripts/components/index.min.js 264 kB -8 B (0%)
build/scripts/core-commands/index.min.js 4.41 kB +74 B (+1.71%)
build/scripts/edit-site/index.min.js 298 kB +974 B (+0.33%)
build/scripts/edit-widgets/index.min.js 22.1 kB -53 B (-0.24%)
build/scripts/editor/index.min.js 472 kB +21 B (0%)
build/scripts/format-library/index.min.js 31 kB +111 B (+0.36%)
build/scripts/media-utils/index.min.js 114 kB +116 B (+0.1%)
build/scripts/preferences/index.min.js 3.31 kB +15 B (+0.46%)
build/styles/block-library/icon/style-rtl.css 323 B +52 B (+19.19%) ⚠️
build/styles/block-library/icon/style-rtl.min.css 252 B +44 B (+21.15%) 🚨
build/styles/block-library/icon/style.css 323 B +52 B (+19.19%) ⚠️
build/styles/block-library/icon/style.min.css 252 B +44 B (+21.15%) 🚨
build/styles/block-library/style-rtl.css 21.7 kB +51 B (+0.24%)
build/styles/block-library/style-rtl.min.css 18.2 kB +45 B (+0.25%)
build/styles/block-library/style.css 21.8 kB +51 B (+0.23%)
build/styles/block-library/style.min.css 18.2 kB +46 B (+0.25%)

compressed-size-action

Comment thread packages/components/CHANGELOG.md Outdated
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M18.5 5.5V8H20V5.5h2.5V4H20V1.5h-1.5V4H16v1.5h2.5zM12 4H6a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2v-6h-1.5v6a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5h6V4z" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="fill: none" stroke="currentColor" stroke-width="1.5">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're now adding a lot of explicit currentColor in the icons themselves. This is going to result in inconsistent behavior across icons.

Here's the icon library in a color: red context:

Before After
Icon library, red context Icon library, red context

Unlike Icon in either wp-components or wp-icons, the new Icon from wp-ui applies a fill="currentColor" by default. Here's the icon library modified to use the wp-ui version:

Icon library using the Icon primitive from wp-ui

If we're going with these stroke-based icons, I think we're probably forced to add explicit currentColor in the icons themselves, for all the icons, not just the ones that have been redrawn here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going with these stroke-based icons, I think we're probably forced to add explicit currentColor in the icons themselves, for all the icons, not just the ones that have been redrawn here.

I volunteer to do that 🙋‍♂️

Before I do, I want to just check with you if you're okay with this? Is it functionally a good choice? IMO yes as this is the implied behavior of the icon set and it's worth making explicit. I also expect to follow up with a PR that adds a script to do this on every build of the set.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good choice. It just has the potential to introduce unexpected visual glitches for consumers receiving this update, but it's probably for the best in the long term and it alings the current behaviour to the new behaviour that @wordpress/ui's Icon component already applies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will also expose a cleaner way to change the icon color: ie. via CSS color, rather than guessing if fill or stroke should be used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I think it's ultimately a tech enhancement that opens up new opportunities.

In that vein, what are some action items for this PR? Do you think we can land this one as-is, or do I need to include all the icons in one go?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best not to increase the scope of this PR further, but we should definitely aim to have a coherent behavior for all icons within the same WordPress release (and possible even Gutenberg release)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icons are easy to redraw, I can do it in days. The problem is this first PR, I'm reluctant to redraw ALL the icons in this PR, if there's a risk this PR doesn't land.

A note, I will be AFK for the summer vacation starting Tuesday, so if something has to happen for 7.1, it has to be this week. I don't think it has to be a 7.1 thing, but sharing that context for clarity regardless.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that "adding explicit currentColor to all icons" is a good thing to do, regardless of this redrawing a subset of the icons to strokes.

Still, if we want to keep PRs as small as possible, I think the order needs to be:

  1. Add currentColor to all the icons.
  2. Redraw a subset of the icons to strokes.

Otherwise, landing the stroke redraw first will get the @wordpress/icons package in a state where some icons get currentColor and some do not. Since the @wordpress/icons is a bundled package and not tied to WordPress/Gutenberg releases, the only thing that matters is the package release. We'll want to avoid any situation where there could be a release of the icons package in a mixed color state.

t-hamano and others added 7 commits June 17, 2026 12:35
Even with `style` in the kses allowlist, wp_kses filters the attribute
value through safecss_filter_attr(), which drops CSS properties not on its
allowlist. SVG presentation properties like `fill` are not allowed, so
`style="fill: none"` was emptied and removed during sanitization, leaving
stroke-based icons with a solid default fill.

Temporarily register a safe_style_css filter while sanitizing to allow the
SVG presentation properties (fill, stroke, stroke-width, stroke-linecap,
stroke-linejoin, stroke-miterlimit) in both the compat base class and the
Gutenberg subclass override.

Additionally, the icon block overwrote the SVG's intrinsic style attribute
when applying block styles. Merge the existing style with the generated CSS
so `fill: none` survives, with block styles last to win on conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Weston Ruter <westonruter@git.wordpress.org>
Co-authored-by: Weston Ruter <westonruter@git.wordpress.org>
Co-authored-by: Weston Ruter <westonruter@git.wordpress.org>
A previous suggestion application landed the JSDoc body without its
opening /** delimiter, which left the file with orphaned * lines that
break Node's parser. Restore the opener so the build runs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Rename splitStyleDeclarations to parseStyleDeclarations and have it
split each declaration on the first un-quoted, un-parenthesised colon
as part of the same tokenisation pass. Returns Array<[key, value]>
instead of string[], so the caller no longer needs a second indexOf
parse to extract the value. Per Weston's review feedback. Adds tests
for the colon-handling edge cases (colons inside parens, quotes, and
`data:` URIs).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Block icon's render: guard against an empty existing style when
  merging block styles, avoiding a leading semicolon when the
  intrinsic style is absent or whitespace-only.
- Icon component: move the explicit style merge before ...restProps
  in the svg branch to match the generic element branch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jasmussen jasmussen force-pushed the update/redraw-34-icons-to-stroke-based branch from 695eed4 to 2b921c0 Compare June 17, 2026 10:36
The override declared stricter types than WP_Icons_Registry::sanitize_icon_content()
in the parent class, triggering a PHP signature-compatibility fatal:

  Declaration of WP_Icons_Registry_Gutenberg::sanitize_icon_content(string $icon_content): string
  must be compatible with WP_Icons_Registry::sanitize_icon_content($icon_content)

Match the parent's untyped signature.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jasmussen

Copy link
Copy Markdown
Contributor Author

Addressed to the best of my ability the feedback, and rebased this branch.

To note, the sanitization-side feedback (DRY, polygon attributes, sanitization tests) is being more comprehensively addressed in @t-hamano's #75550, which is a substantial rework of sanitize_icon_content with a broader allowlist (including polygon with full stroke support) and dedicated tests. Doing intermediate refactors here would create a conflict with that PR. How would you feel about letting 75550 be the single source of truth for the sanitizer?

As for the icon block render tests, here, happy to do a followup. The empty-style edge case should be guarded in code, so perhaps the test could be a followup.

As far as next steps, I wanted to note I'm heading AFK for my summer vacation starting Tuesday next week. I'd love to be able to land this before then, as I believe it's a strong step forward for the icon tech, and it embodies changes so far that are purely invisible, all under-the-hood stuff that we can take advantage of later, notably when the rest of the set is updated to be stroke-based. But if we don't land it before then, I just wanted to make clear that others should feel free to commandeer and push/edit this PR, as well as merge, if they would like.

Finally, I want to flag again that I think it would be useful to land #79116 as a safeguard for the Icon block. It ensures strokes scale like they do today, even as some icons become stroke-based. It would be a temporary safeguard because once the whole set is updated, we would change this to become a toggle instead, so you could choose your appearance, capitalising on the change.

@mirka

mirka commented Jun 17, 2026

Copy link
Copy Markdown
Member

I think I would classify the currentColor inconsistency as a blocker to this PR merging, unless we're sure we can follow up with the consistency fix before the next @wordpress/icons package release.

@jasmussen

Copy link
Copy Markdown
Contributor Author

Thanks for the clarity @mirka. I'd like to propose a way to address that consistency concern, I have it working locally but it's unpushed, since it will involve adding an additional 295 changes to this commit, I'd love to share the brief and pitch with you first, before I commit.

The pitch is that we add a small source-normalization step to packages/icons/lib/generate-library.cjs (the icons package's existing build script), then run it once to canonicalize all current source SVGs.

This script I've run locally, and validated that it works. What it does is add a new function to the existing build script. It's wired into main() so it runs on every npm run build, which means future icon additions self-normalize. Here's the script:

async function normalizeSourceIcons() {
	const svgFiles = ( await readdir( ICON_LIBRARY_DIR ) ).filter( ( file ) =>
		file.match( /^[a-z0-9--]+\.svg$/ )
	);

	await Promise.all(
		svgFiles.map( async ( svgFile ) => {
			const svgPath = path.join( ICON_LIBRARY_DIR, svgFile );
			const original = await readFile( svgPath, 'utf8' );

			const updated = original.replace(
				/^(<svg\b)([^>]*)>/,
				( match, openTag, attrs ) => {
					// Skip if outer <svg> already declares fill via attribute.
					if ( /\sfill\s*=/.test( attrs ) ) {
						return match;
					}
					// Skip if outer <svg> declares fill via inline style.
					if ( /\sstyle\s*=\s*"[^"]*\bfill\b/.test( attrs ) ) {
						return match;
					}
					return `${ openTag }${ attrs } fill="currentColor">`;
				}
			);

			if ( updated !== original ) {
				await writeFile( svgPath, updated );
			}
		} )
	);
}

When I re-run it on already-normalised source files, it produces no changes.

In testing locally, it changed 295 icons, left 35 unchanged (the ones redrawn in this PR), coming to 330 total.

It ignored the 35 as they all have style="fill: none" on the outer element. For the icons changed, it looks like this:

-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">

If you approve, I'd make two commits:

  1. The script: generate-library.cjs
  2. The normalized icons, a 295-file diff, each with a single-line attribute addition.

I propose to do it in this PR, but it could also be a separte PR, or a "branch on the branch". I'd like to do it in this PR as I will be AFK from Tuesday next week, back July 8th. But I an also put it in a separate branch, so long as we remember to land both in short succession. E.g. I already think #79116 would be good to pair with this.

Also to be clear: I do welcome commits from others, and to merge or even revert if something happens, in my absence.

Let me know!

@mirka

mirka commented Jun 18, 2026

Copy link
Copy Markdown
Member

The color normalization is a completely separate concern to this PR, and warrants dedicated review and documentation of our reasoning. So let's do it in a separate PR. If you can push the relevant changes that you made, I can drive it forward while you're out 👍

In terms of specifics, I have a feeling we should just normalize the existing SVGs with your script now and commit the changes permanently, rather than keeping the script as part of the build script. If we find that new icons get added without the necessary colors, we can maybe add a lint rule later.

@jasmussen

Copy link
Copy Markdown
Contributor Author

Solid feedback, and thanks so much for all the help.

I've now pushed an entirely separate PR, #79320, which does as you propose. First it updates all the icons. The second is the optional helper script, but no longer tied to npm run build. We can keep or delete that second commit. But honestly it works pretty well even as a test: if you run it and it doesn't change a thing, that means all the icons are as they should.

Let me know if this works for you! Thanks @mirka.

t-hamano and others added 3 commits June 19, 2026 15:54
The global safe_style_css filter added in #79172
(lib/compat/wordpress-7.1/kses.php) now allowlists SVG presentation
properties, so the per-call filter that temporarily allowed fill/stroke
properties during wp_kses() is redundant.

Co-Authored-By: Claude <noreply@anthropic.com>
Same cleanup as the previous commit, applied to the WP 7.0 compat base
class. The global safe_style_css filter from #79172 covers the SVG
presentation properties, making the per-call filter redundant here too.

Co-Authored-By: Claude <noreply@anthropic.com>
@t-hamano

Copy link
Copy Markdown
Contributor

Update: Since #79172 has been merged, we no longer need to hack the safe_style_css filter. I have removed them in 136d5ef and dd1c3d0.

t-hamano and others added 2 commits June 19, 2026 16:03
Remove the explanatory comment about the global safe_style_css filter
from the WP 7.0 base class for a cleaner sanitize_icon_content().

Co-Authored-By: Claude <noreply@anthropic.com>
@t-hamano t-hamano force-pushed the update/redraw-34-icons-to-stroke-based branch from cdade30 to bd8c908 Compare June 19, 2026 07:50
@t-hamano

Copy link
Copy Markdown
Contributor

Finally, I want to flag again that I think it would be useful to land #79116 as a safeguard for the Icon block. It ensures strokes scale like they do today, even as some icons become stroke-based. It would be a temporary safeguard because once the whole set is updated, we would change this to become a toggle instead, so you could choose your appearance, capitalising on the change.

Since the visual changes to the icon block are caused by this PR, I think it is best to add the safeguard directly in this PR.

Let's close #79116 as I've pushed the bd8c908 to this PR.

@jasmussen

Copy link
Copy Markdown
Contributor Author

Thanks for all the help @t-hamano, much appreciated 🏅

I saw you added icon-block changes to this PR. I agree with those changes to safeguard the Icon block, but just noting that means we won't need the separate #79116.

@jasmussen

Copy link
Copy Markdown
Contributor Author

Hah, we commented at the same time. Full agreement! I'll close 79116

@t-hamano

Copy link
Copy Markdown
Contributor

As a side note, if this PR is shipped, it might require a dev note, as it could significantly impact consumers using the @wordpress/icons package.

  • Why were the icons redrawn with a stroke base
  • What CSS should be written to maintain the previous appearance
  • What are the plans for future icon enhancements

@jasmussen

Copy link
Copy Markdown
Contributor Author

If we need such a dev note, here's a draft:

The icons were redrawn with a stroke base primarily to enable size-independent stroke widths. They use vector-effect="non-scaling-stroke", which keeps stroke thickness constant regardless of the icon's display size, so icons of different sizes (16 / 20 / 24 / 32 px) can be mixed in the same UI and still read as a uniform set. This also lays the foundation for future enhancements: both the design system and the Icon block can gain a way to adjust stroke-width as a design property, and a parallel effort is updating all icons in @wordpress/icons to self-declare their colour via fill="currentColor" so they render correctly without consumers having to inject fill: currentColor via CSS.

No CSS changes should be necessary after this change. Stroke-only icons additionally set an inline style="fill: none" so they remain resilient to ordinary overrides. The one case to watch for is CSS that sets fill on svg (or its children) using !important, which will defeat that protection and may cause stroke icons to render as solid shapes. In this case, remove the !important. Separately, if your design intentionally relied on the older behaviour where stroke weight scaled with the icon's size, you can restore it by overriding vector-effect:

svg :where(path, rect, circle, ellipse, line, polygon, polyline) {
	vector-effect: none;
}

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

Labels

[Feature] Icons Related to Icon registration API and Icon REST API [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Components /packages/components [Package] Edit Site /packages/edit-site [Package] Icons /packages/icons [Type] Enhancement A suggestion for improvement.

Projects

Status: 🔎 Needs Review

Development

Successfully merging this pull request may close these issues.

8 participants