Make WordPress Core


Ignore:
Timestamp:
02/15/2026 08:09:39 AM (3 months ago)
Author:
fabiankaegy
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/colors/_mixins.scss

    r59656 r61645  
    11@use 'sass:color';
     2@use 'tokens';
    23
    34/*
    4  * Button mixin- creates a button effect with correct
    5  * highlights/shadows, based on a base color.
     5 * Button mixin - creates a primary button effect.
     6 * Uses CSS custom properties for theme color support across color schemes.
    67 */
    7 @mixin button( $button-color, $button-text-color: #fff ) {
    8     background: $button-color;
    9     border-color: $button-color;
     8@mixin button( $button-text-color: #fff ) {
     9    background: var(--wp-admin-theme-color);
     10    border-color: transparent;
     11    border-radius: tokens.$radius-s;
    1012    color: $button-text-color;
    1113
    12     &:hover,
    13     &:focus {
    14         background: color.adjust($button-color, $lightness: 3%);
    15         border-color: color.adjust($button-color, $lightness: -3%);
     14    &:hover {
     15        background: var(--wp-admin-theme-color-darker-10);
     16        border-color: transparent;
    1617        color: $button-text-color;
    1718    }
    1819
    1920    &:focus {
     21        background: var(--wp-admin-theme-color);
     22        border-color: transparent;
     23        color: $button-text-color;
     24        /* Gutenberg-style focus ring: outer theme color + inset white for contrast */
    2025        box-shadow:
    21             0 0 0 1px #fff,
    22             0 0 0 3px $button-color;
     26            0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color),
     27            inset 0 0 0 1px tokens.$white;
     28        /* Visible in Windows High Contrast mode */
     29        outline: 1px solid transparent;
    2330    }
    2431
    2532    &:active {
    26         background: color.adjust($button-color, $lightness: -5%);
    27         border-color: color.adjust($button-color, $lightness: -5%);
     33        background: var(--wp-admin-theme-color-darker-20);
     34        border-color: transparent;
    2835        color: $button-text-color;
     36    }
     37
     38    &:disabled,
     39    &.disabled {
     40        background: tokens.$gray-100;
     41        border-color: transparent;
     42        color: tokens.$gray-600;
     43        cursor: not-allowed;
    2944    }
    3045
     
    3247    &.active:focus,
    3348    &.active:hover {
    34         background: $button-color;
     49        background: var(--wp-admin-theme-color-darker-10);
    3550        color: $button-text-color;
    36         border-color: color.adjust($button-color, $lightness: -15%);
    37         box-shadow: inset 0 2px 5px -3px color.adjust($button-color, $lightness: -50%);
     51        border-color: transparent;
     52        box-shadow: none;
    3853    }
    3954}
     55
     56/*
     57 * Secondary button mixin - outlined style with theme color.
     58 * Matches Gutenberg's .is-secondary button variant.
     59 */
     60@mixin button-secondary() {
     61    background: transparent;
     62    border: 1px solid var(--wp-admin-theme-color);
     63    border-radius: tokens.$radius-s;
     64    color: var(--wp-admin-theme-color);
     65
     66    &:hover {
     67        background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
     68        border-color: var(--wp-admin-theme-color-darker-20);
     69        color: var(--wp-admin-theme-color-darker-20);
     70    }
     71
     72    &:focus {
     73        background: transparent;
     74        border-color: var(--wp-admin-theme-color);
     75        color: var(--wp-admin-theme-color);
     76        box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
     77        outline: 1px solid transparent;
     78    }
     79
     80    &:active {
     81        background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
     82        border-color: var(--wp-admin-theme-color-darker-20);
     83        color: var(--wp-admin-theme-color-darker-20);
     84        box-shadow: none;
     85    }
     86
     87    &:disabled,
     88    &.disabled {
     89        background: transparent;
     90        border-color: tokens.$gray-300;
     91        color: tokens.$gray-600;
     92        cursor: not-allowed;
     93    }
     94}
     95
     96/*
     97 * Tertiary button mixin - transparent background, gray text.
     98 */
     99@mixin button-tertiary() {
     100    background: transparent;
     101    border: 1px solid tokens.$gray-600;
     102    border-radius: tokens.$radius-s;
     103    color: tokens.$gray-900;
     104
     105    &:hover {
     106        background: rgba(0, 0, 0, 0.05);
     107        border-color: tokens.$gray-700;
     108        color: tokens.$gray-900;
     109    }
     110
     111    &:focus {
     112        background: transparent;
     113        border-color: var(--wp-admin-theme-color);
     114        color: tokens.$gray-900;
     115        box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
     116        outline: 1px solid transparent;
     117    }
     118
     119    &:active {
     120        background: rgba(0, 0, 0, 0.1);
     121        border-color: tokens.$gray-700;
     122        color: tokens.$gray-900;
     123    }
     124
     125    &:disabled,
     126    &.disabled {
     127        background: transparent;
     128        border-color: tokens.$gray-400;
     129        color: tokens.$gray-600;
     130        cursor: not-allowed;
     131    }
     132}
Note: See TracChangeset for help on using the changeset viewer.