Gutenberg Button blocks are styled incorrectly in widget areas
-
The styles in
/assets/css/src/_widgets.scss
don’t account for Gutenberg Button blocks (which are technically anchor elements). For example, consider the following rule:.widget-area a:not(.button) { color: var(--global-palette3); text-decoration: none; &:hover { color: var(--global-palette-highlight); text-decoration: underline; } }
Because the
:not()
excludes only elements with the.button
class, a Gutenberg Block button will be incorrectly styled as if it were a normal link.There are a couple additional classes you should target to fix this:
–
wp-element-button
is the new standard class name applied to all front-end buttons (both literal button elements and links styled to look like buttons) rendered by core Gutenberg blocks (e.g. the Search block or Button block). However, it was only introduced quite recently (Gutenberg 13.4), and it is currently not applied retroactively to statically-rendered blocks (unless you open and resave the post they’re contained in).
–wp-block-button__link
is a class applied to the<a>
element of Button blocks. Note that you can’t just targetwp-block-button
because (for legacy reasons) each Button block has a<div>
wrapper as its root element, so you’d be targeting the wrong element.In short, everything that currently targets
.button
should probably also target.wp-element-button
andwp-block-button__link
.For reference:
- The topic ‘Gutenberg Button blocks are styled incorrectly in widget areas’ is closed to new replies.