Files
wordpress/wp-includes/css/buttons.css
fabiankaegy cc0fed3547 Admin: Update button and form field styles to align with the design system.
Introduce a design system tokens file (`_tokens.scss`) based on the WordPress Design System, providing standardized values for colors, spacing, typography, border-radius, and elevation.

Update buttons to use CSS custom properties for theme color support across all admin color schemes. Restyle primary buttons with filled theme-color backgrounds, secondary buttons with outlined borders, and add a tertiary button mixin. Adopt Gutenberg-style focus rings with outset box-shadows and transparent outlines for Windows High Contrast mode compatibility.

Increase default input and select height from 30px to 40px, apply 2px border-radius, and update border and placeholder colors to match the design system. Restyle checkboxes and radios with filled theme-color checked states and white indicator marks, using outset double-ring focus styles consistent with Gutenberg.

Apply compact 32px sizing to list table controls, page-title-action buttons, and toolbar elements. Convert tag input layouts and the major-publishing-actions bar to flexbox.

Props fabiankaegy, joedolson, audrasjb, joen, phpbits, magaliechetrit, karmatosed.
Fixes #64547.


Built from https://develop.svn.wordpress.org/trunk@61645


git-svn-id: http://core.svn.wordpress.org/trunk@60956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-02-15 08:10:37 +00:00

454 lines
12 KiB
CSS

/* ----------------------------------------------------------------------------
NOTE: If you edit this file, you should make sure that the CSS rules for
buttons in the following files are updated.
* jquery-ui-dialog.css
* editor.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.
Button Styles
-------------
To display a primary button style, add the `.button-primary` class to a button.
Button Sizes
------------
Adjust a button's size by adding the `.button-large` or `.button-small` class.
Button States
-------------
Lock the state of a button by adding the name of the pseudoclass as
an actual class (e.g. `.hover` for `:hover`).
TABLE OF CONTENTS:
------------------
1.0 - Button Layouts
2.0 - Default Button Style
3.0 - Primary Button Style
4.0 - Button Groups
5.0 - Responsive Button Styles
---------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
1.0 - Button Layouts
---------------------------------------------------------------------------- */
.wp-core-ui .button,
.wp-core-ui .button-primary,
.wp-core-ui .button-secondary {
display: inline-block;
text-decoration: none;
font-size: 13px;
font-weight: 500;
line-height: 2.92307692; /* 38px - allows 40px min-height with 1px border */
min-height: 40px;
margin: 0;
padding: 0 16px;
cursor: pointer;
border-width: 1px;
border-style: solid;
-webkit-appearance: none;
border-radius: 2px;
white-space: nowrap;
box-sizing: border-box;
}
/* Remove the dotted border on :focus and the extra padding in Firefox */
.wp-core-ui button::-moz-focus-inner,
.wp-core-ui input[type="reset"]::-moz-focus-inner,
.wp-core-ui input[type="button"]::-moz-focus-inner,
.wp-core-ui input[type="submit"]::-moz-focus-inner {
border-width: 0;
border-style: none;
padding: 0;
}
/* Compact size - 32px, for space-constrained contexts */
.wp-core-ui .button.button-compact,
.wp-core-ui .button-group.button-compact .button {
line-height: 2.30769231; /* 30px - allows 32px min-height with 1px border */
min-height: 32px;
padding: 0 12px;
}
/* Small size - 24px */
.wp-core-ui .button.button-small,
.wp-core-ui .button-group.button-small .button {
line-height: 2; /* 22px - allows 24px min-height with 1px border */
min-height: 24px;
padding: 0 8px;
font-size: 11px;
}
/* Large size - explicit 40px (same as default, for semantic clarity) */
.wp-core-ui .button.button-large,
.wp-core-ui .button-group.button-large .button {
line-height: 2.92307692; /* 38px - allows 40px min-height with 1px border */
min-height: 40px;
padding: 0 16px;
}
.wp-core-ui .button.button-hero,
.wp-core-ui .button-group.button-hero .button {
font-size: 14px;
line-height: 3.28571429; /* 46px - allows 48px min-height with 1px border */
min-height: 48px;
padding: 0 36px;
}
.wp-core-ui .button.hidden {
display: none;
}
/* Button Icons - Dashicons centering for all button sizes */
/* Dashicons are 20px font-size, so line-height = target-height / 20 */
.wp-core-ui .button .dashicons,
.wp-core-ui .button-primary .dashicons,
.wp-core-ui .button-secondary .dashicons {
line-height: 1.9; /* 38px (20px * 1.9) - matches default button */
vertical-align: top;
}
.wp-core-ui .button.button-compact .dashicons {
line-height: 1.5; /* 30px (20px * 1.5) - matches compact button */
}
.wp-core-ui .button.button-small .dashicons {
line-height: 1.1; /* 22px (20px * 1.1) - matches small button */
}
.wp-core-ui .button.button-hero .dashicons {
line-height: 2.3; /* 46px (20px * 2.3) - matches hero button */
}
/* Style Reset buttons as simple text links */
.wp-core-ui input[type="reset"],
.wp-core-ui input[type="reset"]:hover,
.wp-core-ui input[type="reset"]:active,
.wp-core-ui input[type="reset"]:focus {
background: none;
border: none;
box-shadow: none;
padding: 0 2px 1px;
width: auto;
}
/* ----------------------------------------------------------------------------
2.0 - Default Button Style
---------------------------------------------------------------------------- */
.wp-core-ui .button,
.wp-core-ui .button-secondary {
color: var(--wp-admin-theme-color);
border-color: var(--wp-admin-theme-color);
background: transparent;
vertical-align: top;
}
.wp-core-ui p .button {
vertical-align: baseline;
}
.wp-core-ui .button.hover,
.wp-core-ui .button:hover,
.wp-core-ui .button-secondary:hover {
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
border-color: var(--wp-admin-theme-color-darker-20);
color: var(--wp-admin-theme-color-darker-20);
}
.wp-core-ui .button.focus,
.wp-core-ui .button:focus,
.wp-core-ui .button-secondary:focus {
background: transparent;
border-color: var(--wp-admin-theme-color);
color: var(--wp-admin-theme-color);
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
/* Only visible in Windows High Contrast mode */
outline: 1px solid transparent;
/* Reset inherited offset from Gutenberg */
outline-offset: 0;
}
/* :active state */
.wp-core-ui .button:active,
.wp-core-ui .button-secondary:active {
background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
border-color: var(--wp-admin-theme-color-darker-20);
color: var(--wp-admin-theme-color-darker-20);
box-shadow: none;
}
/* pressed state e.g. a selected setting */
.wp-core-ui .button.active,
.wp-core-ui .button.active:hover {
background-color: rgba(var(--wp-admin-theme-color--rgb), 0.04);
color: var(--wp-admin-theme-color);
border-color: var(--wp-admin-theme-color);
box-shadow: none;
}
.wp-core-ui .button.active:focus {
border-color: var(--wp-admin-theme-color);
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
}
.wp-core-ui .button[disabled],
.wp-core-ui .button:disabled,
.wp-core-ui .button.disabled,
.wp-core-ui .button-secondary[disabled],
.wp-core-ui .button-secondary:disabled,
.wp-core-ui .button-secondary.disabled,
.wp-core-ui .button-disabled {
color: #949494 !important;
border-color: #dddddd !important;
background: transparent !important;
box-shadow: none !important;
cursor: default;
transform: none !important;
}
.wp-core-ui .button[aria-disabled="true"],
.wp-core-ui .button-secondary[aria-disabled="true"] {
cursor: default;
}
/* Buttons that look like links, for a cross of good semantics with the visual */
.wp-core-ui .button-link {
margin: 0;
padding: 0;
box-shadow: none;
border: 0;
border-radius: 0;
background: none;
cursor: pointer;
text-align: left;
/* Mimics the default link style in common.css */
color: var(--wp-admin-theme-color);
text-decoration: underline;
transition-property: border, background, color;
transition-duration: .05s;
transition-timing-function: ease-in-out;
}
.wp-core-ui .button-link:hover,
.wp-core-ui .button-link:active {
color: var(--wp-admin-theme-color-darker-20);
}
.wp-core-ui .button-link:focus {
color: var(--wp-admin-theme-color);
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
border-radius: 2px;
/* Only visible in Windows High Contrast mode */
outline: 1px solid transparent;
}
.wp-core-ui .button-link-delete {
color: #d63638;
}
.wp-core-ui .button-link-delete:hover,
.wp-core-ui .button-link-delete:focus {
color: #d63638;
background: transparent;
}
.wp-core-ui .button-link-delete:disabled {
/* overrides the default buttons disabled background */
background: transparent !important;
}
/* ----------------------------------------------------------------------------
3.0 - Primary Button Style
---------------------------------------------------------------------------- */
.wp-core-ui .button-primary {
background: var(--wp-admin-theme-color);
border-color: var(--wp-admin-theme-color);
color: #fff;
text-decoration: none;
text-shadow: none;
}
.wp-core-ui .button-primary.hover,
.wp-core-ui .button-primary:hover {
background: var(--wp-admin-theme-color-darker-10);
border-color: var(--wp-admin-theme-color-darker-10);
color: #fff;
}
.wp-core-ui .button-primary.focus,
.wp-core-ui .button-primary:focus {
background: var(--wp-admin-theme-color);
border-color: var(--wp-admin-theme-color);
color: #fff;
box-shadow:
0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color),
inset 0 0 0 1px #fff;
outline: 1px solid transparent;
}
.wp-core-ui .button-primary.active,
.wp-core-ui .button-primary.active:hover,
.wp-core-ui .button-primary.active:focus,
.wp-core-ui .button-primary:active {
background: var(--wp-admin-theme-color-darker-20);
border-color: var(--wp-admin-theme-color-darker-20);
box-shadow: none;
color: #fff;
}
.wp-core-ui .button-primary[disabled],
.wp-core-ui .button-primary:disabled,
.wp-core-ui .button-primary-disabled,
.wp-core-ui .button-primary.disabled {
color: #949494 !important;
background: #f0f0f0 !important;
border-color: #f0f0f0 !important;
box-shadow: none !important;
text-shadow: none !important;
cursor: default;
}
.wp-core-ui .button-primary[aria-disabled="true"] {
cursor: default;
}
/* ----------------------------------------------------------------------------
4.0 - Button Groups
---------------------------------------------------------------------------- */
.wp-core-ui .button-group {
position: relative;
display: inline-block;
white-space: nowrap;
font-size: 0;
vertical-align: middle;
}
.wp-core-ui .button-group > .button {
display: inline-block;
border-radius: 0;
margin-right: -1px;
}
.wp-core-ui .button-group > .button:first-child {
border-radius: 2px 0 0 2px;
}
.wp-core-ui .button-group > .button:last-child {
border-radius: 0 2px 2px 0;
}
.wp-core-ui .button-group > .button-primary + .button {
border-left: 0;
}
.wp-core-ui .button-group > .button:focus {
position: relative;
z-index: 1;
}
/* pressed state e.g. a selected setting */
.wp-core-ui .button-group > .button.active {
background-color: #dcdcde;
color: #135e96;
border-color: #0a4b78;
box-shadow: inset 0 2px 5px -3px #0a4b78;
}
.wp-core-ui .button-group > .button.active:focus {
border-color: #3582c4;
box-shadow:
inset 0 2px 5px -3px #0a4b78,
0 0 0 1px #3582c4;
}
/* ----------------------------------------------------------------------------
5.0 - Responsive Button Styles
---------------------------------------------------------------------------- */
@media screen and (max-width: 782px) {
.wp-core-ui .button,
.wp-core-ui .button.button-large,
.wp-core-ui .button.button-small,
input#publish,
input#save-post,
a.preview {
padding: 0 14px;
line-height: 2.71428571; /* 38px - allows 40px min-height with 1px border */
font-size: 14px;
vertical-align: middle;
min-height: 40px;
margin-bottom: 4px;
}
/* Responsive Button Icons - Dashicons centering */
.wp-core-ui .button .dashicons,
.wp-core-ui .button-primary .dashicons,
.wp-core-ui .button-secondary .dashicons {
line-height: 1.9; /* 38px (20px * 1.9) - matches responsive button */
}
/* Copy attachment URL button in the legacy edit media page. */
.wp-core-ui .copy-to-clipboard-container .copy-attachment-url {
margin-bottom: 0;
}
#media-upload.wp-core-ui .button {
padding: 0 10px;
line-height: 1.69230769; /* 22px */
min-height: 24px;
font-size: 13px;
}
.media-frame.mode-grid .bulk-select .button {
margin-bottom: 0;
}
/* Publish Metabox Options */
.wp-core-ui .save-post-status.button {
position: relative;
margin: 0 14px 0 10px; /* 14px right margin to match all other buttons */
}
/* Reset responsive styles in Press This, Customizer */
.wp-core-ui.wp-customizer .button {
font-size: 13px;
line-height: 2.30769231; /* 30px */
min-height: 32px;
margin: 0;
vertical-align: inherit;
}
.wp-customizer .theme-overlay .theme-actions .button {
margin-bottom: 5px;
}
.media-modal-content .media-toolbar-primary .media-button {
margin-top: 10px;
margin-left: 5px;
}
/* Reset responsive styles on Log in button on iframed login form */
.interim-login .button.button-large {
min-height: 32px;
line-height: 2.30769231; /* 30px */
padding: 0 12px;
}
}