Opened 8 years ago
Closed 8 years ago
#37138 closed defect (bug) (fixed)
Audit usage of the buttons CSS classes
Reported by: | afercia | Owned by: | afercia |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | ui-feedback |
Focuses: | ui | Cc: |
Description
Looks like the buttons styling in WordPress is built in a way that the "base" CSS class .button
should always be used. Then, controls (links or buttons) may have additional classes like .button-primary
and .button-secondary
.
By the way, there are places where the base class is missing and elements use only .button-primary
or .button-secondary
. This affects the focus style when elements are focused, and it actually depends also on the platform and browser used.
For example, the buttons in the Quick Edit form miss the base .button
class and this is how they look in Chrome on OS X:
This happens because the native outline
style (which is different across platforms and browsers) is reset only by the base .button
CSS class:
.wp-core-ui .button:active, .wp-core-ui .button:focus { outline: none; }
Worth noting links that look like buttons are not affected because common.css
already resets the links outline. So this applies just to buttons, see in the screenshots below:
There are probably two options:
- check all the buttons and make sure they have the
.button
class - just reset the outline also in the other button CSS rules
Related: #34904
Change History (10)
This ticket was mentioned in Slack in #design by afercia. View the logs.
8 years ago
This ticket was mentioned in Slack in #design by oric. View the logs.
8 years ago
#4
@
8 years ago
Turns out I was partially wrong and worth clarifying that the .button-secondary
class is there just for backward
compatibility reasons and should not be used. From wp-includes/css/buttons.css
:
WordPress-style Buttons ======================= Create a button by adding the `.button` class to an element. For backward compatibility, we support several other classes (such as `.button-secondary`), but these will *not* work with the stackable classes described below.
#6
@
8 years ago
@karmatosed yep, the outline property should be reset for all the buttons. I think that's the intended behaviour, it doesn't work well in some cases just because the classes are used incorrectly.
#7
@
8 years ago
- Milestone changed from Awaiting Review to 4.7
- Owner set to afercia
- Status changed from new to assigned
One more example is about a few places where button-large
is used without the base class button
. For example, in the edit attachment screen, the primary button in the publish box uses these classes:
button-primary button-large
and they should be
button button-primary button-large
Currently, this button has the standard size, with a height of 28px:
but it should be a bit bigger, also for consistency with the similar button in the Post Publish meta box:
The base class button
is necessary also to properly reset the outline property, see what happens in Chrome on OS X without the button
class:
and with:
I would prefer to add the selector *[class*='button-'] after .button selector. So it may look like this: