Skip to content

Put the icon and label in a row despite core's button styles - #10

Merged
tomjn merged 1 commit into
mainfrom
fix/row-layout-beats-core
Sep 24, 2026
Merged

tomjn merged 1 commit into
mainfrom
fix/row-layout-beats-core

Conversation

@tomjn

@tomjn tomjn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

The row layout rule was written in :where() so a theme could override it with anything. But core's own button stylesheet sets display: inline-block on 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 ::before icon with flex.

display and align-items now carry a class each, just enough to beat core. gap and justify-content stay 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.

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.

@goldenapples goldenapples left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Makes sense to me.

@tomjn
tomjn merged commit 427e0d3 into main Sep 24, 2026
1 check passed
@jdbg
jdbg deleted the fix/row-layout-beats-core branch September 24, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants