Put the icon and label in a row despite core's button styles - #10
Merged
Merged
Conversation
Core's button stylesheet sets display: inline-block on every .wp-block-button__link, and the row rule was in :where(), so it never applied. The icon and label sat side by side as top aligned inline boxes, so the icon rode above the text and the button grew taller. The display and alignment now carry a class each, and the gap stays in :where() for themes to change.
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.
The row layout rule was written in
:where()so a theme could override it with anything. But core's own button stylesheet setsdisplay: inline-blockon every.wp-block-button__link, and a zero specificity rule loses to it on every site, so the rule never applied. The icon and label sat side by side as inline boxes aligned to the top, so the icon rode above the text and the button grew taller than a button without an icon. The editor canvas has the same problem, since it orders its::beforeicon with flex.displayandalign-itemsnow carry a class each, just enough to beat core.gapandjustify-contentstay in:where(), so a theme can still change them with any selector. The README and CLAUDE.md said the whole rule was deliberately specificity free, and now say which half is and why.Checked on a WordPress 7.1 site with no theme override: an icon button is now the same height as one without an icon, and the icon and label share a vertical centre.