Administration: Replace hardcoded 0.5px focus styles with the standard focus-width variable - #12601
Administration: Replace hardcoded 0.5px focus styles with the standard focus-width variable#12601i-am-chitti wants to merge 4 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| border-color: var(--wp-admin-theme-color); | ||
| border-radius: 2px; | ||
| box-shadow: 0 0 0 0.5px var(--wp-admin-theme-color); | ||
| box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color); |
There was a problem hiding this comment.
This appears to be duplicated in other stylesheets but It's better to have it duplicated rather than having the password toggle button focus unstyled in some edge cases.
There was a problem hiding this comment.
Pull request overview
This PR standardizes several admin (and media modal) focus styles by replacing hardcoded 0.5px box-shadow spreads with the shared --wp-admin-border-width-focus custom property (with a 1.5px fallback), improving focus ring consistency and avoiding sub-pixel rendering.
Changes:
- Updated focus ring thickness in password-related controls (
forms.css) and Media modal form controls (media-views.css) to usevar(--wp-admin-border-width-focus, 1.5px). - Tweaked Menus “tabs panel” focus styling (
edit.css) so the border color matches the focus ring color. - Added a new focus treatment to the list-table view switch links (
list-tables.css), including a transparent border and a:focusborder-color change.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/wp-includes/css/media-views.css | Replaces a hardcoded 0.5px focus shadow spread with the shared focus-width variable. |
| src/wp-admin/css/forms.css | Updates focus shadows for password-related controls to use the standard focus-width variable. |
| src/wp-admin/css/edit.css | Aligns the tabs panel border color with the focus ring color for a more uniform focus indicator. |
| src/wp-admin/css/list-tables.css | Introduces a new focus indicator approach for the view-switch links (transparent border + focused border color). |
Comments suppressed due to low confidence (1)
src/wp-admin/css/list-tables.css:785
- This PR is described as only replacing hardcoded
0.5pxfocus styles, and the description explicitly calls out view-switch links as out of scope. The changes here add a new focus treatment for.view-switch a, so the PR description (and/or scope) should be updated to reflect this additional change, or the change should be moved to a separate PR.
.view-switch a:focus {
border-color: var(--wp-admin-theme-color);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| line-height: 1.84615384; | ||
| text-decoration: none; | ||
| /* This border is needed for the focus style, which will change the border color. */ | ||
| border: 1px solid transparent; | ||
| } |
| 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: 2px solid transparent; | ||
| } |
There was a problem hiding this comment.
The feedback for the password quality uses colored red, orange, green border colors, see:
- #pass1.short
- #pass1.bad
- #pass1.good
- #pass1.strong
the focus style is thinner than expected. I'd rather see a consistent focus style and I'm OK to have the colored border not visible on focus. It is still visible when the input field is not focused.
I'm going to push a change to add the border-color to the focus style. Screenshot before and after:
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/wp-admin/css/list-tables.css:772
- Adding a
1pxborder to.view-switch awhile it also has explicitwidth/heightwill increase the element’s rendered size unlessbox-sizing: border-boxis set. This can cause small layout shifts in the view-switch controls.
Set box-sizing: border-box on the link so the border is included in the declared dimensions.
line-height: 1.84615384;
text-decoration: none;
/* This border is needed for the focus style, which will change the border color. */
border: 1px solid transparent;
}
src/wp-admin/css/forms.css:741
#pass1:focus/#pass1-text:focusnow setsborder-color, which overrides the password-strength state colors (#pass1.short,.bad,.good,.strong) while the field is focused (same specificity, later rule). That makes the strength feedback harder to see while typing.
If the intent is only to adjust the focus ring thickness, consider removing the border-color override so the strength classes can continue to control the border.
#pass1:focus,
#pass1-text:focus {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
border-color: var(--wp-admin-theme-color, #3858e9);
/* Only visible in Windows High Contrast mode */
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
src/wp-admin/css/list-tables.css:767
- Adding a 1px border to
.view-switch achanges the element’s rendered size because the rule also sets fixedwidth/heightand there is nobox-sizing: border-boxhere. That can subtly shift the view-switch layout. Consider settingbox-sizing: border-boxso the border is included in the 28px/36px sizing.
.view-switch a {
float: left;
width: 28px;
height: 28px;
text-align: center;
src/wp-admin/css/edit.css:1393
- This new
border-colorrelies on--wp-admin-theme-colorbut the box-shadow line already includes a fallback color. Adding the same fallback here avoids the border staying gray if the custom property is unavailable.
border-color: var(--wp-admin-theme-color);
src/wp-admin/css/list-tables.css:786
- This introduces a new focus treatment for the list/grid
.view-switchlinks (adding a border and changing its color on focus), but the PR description/title focus on replacing hardcoded0.5pxfocus widths and even call out view-switch links as out-of-scope. Please either update the PR description/scope to include this change, or move it to a separate PR.
.view-switch a:focus {
/* This focus style already inherits box-shadow and outline from the regular links focus style. */
border-color: var(--wp-admin-theme-color, #3858e9);
}
After the admin reskin in WordPress 7.0, the focus style for various elements in the admin was slightly inconsistent especially regarding the overall border plus box-shadow thickness. This change aims to fix most of the cases found and it's a consistency improvement over what it's in WordPress 7.0. Developed in #12601 Props iamchitti, afercia. Fixes #65645. git-svn-id: https://develop.svn.wordpress.org/trunk@62942 602fd350-edb4-49c9-b593-d223f7449a82
After the admin reskin in WordPress 7.0, the focus style for various elements in the admin was slightly inconsistent especially regarding the overall border plus box-shadow thickness. This change aims to fix most of the cases found and it's a consistency improvement over what it's in WordPress 7.0. Developed in WordPress/wordpress-develop#12601 Props iamchitti, afercia. Fixes #65645. Built from https://develop.svn.wordpress.org/trunk@62942 git-svn-id: http://core.svn.wordpress.org/trunk@62186 1a063a9b-81f0-0310-95a4-ce76da25c4cd

Ticket
https://core.trac.wordpress.org/ticket/65645
What & why
Since the 7.0 admin refresh, a few focus styles regressed to a hardcoded
box-shadow: 0 0 0 0.5px.0.5pxis a sub-pixel value — the browser rounds or anti-aliases it, so the focus indicator renders thinner and less reliably than intended.This PR replaces those values with the
--wp-admin-border-width-focuscustom property (fallback1.5px), the pattern already used across the admin styles. It resolves to:@media (min-resolution: 192dpi)),so the ring always maps to whole physical pixels and avoids sub-pixel rounding.
Changes
wp-admin/css/forms.css—#pass1/#pass1-textand.mailserver-pass-wrap .button.wp-hide-pw:0.5px→var(--wp-admin-border-width-focus, 1.5px).wp-includes/css/media-views.css—.media-frameinputs /select/textarea:0.5px→var(--wp-admin-border-width-focus, 1.5px).wp-admin/css/edit.css—div.tabs-panel-active:focus: addborder-color: var(--wp-admin-theme-color)so the 1px border and the box-shadow form a single uniform ring (a consistency fix; not a thin-value change — this selector already used the variable).Only the authored LTR source files are committed;
-rtl.css/.min.cssare build artifacts regenerated viagrunt rtl cssmin.Why the password case was hard to spot
The
#pass1and.wp-hide-pwselectors are also defined — correctly — in the admin color scheme (colors/_admin.scss→colors/*/colors.css), which loads afterforms.csson admin pages and masks the thin rule there. So the password regression is most visible on the Reset Password screen (wp-login.php), which loads no color scheme — where it was originally reported. The.media-frameand.tabs-panelcases have no such duplicate, so they are visible directly on their admin screens.Testing instructions
wp-login.php?action=rp&...): focus New password. Computedbox-shadowshould be... var(--wp-admin-border-width-focus, 1.5px) ...(→ 2px, or 1.5px on HiDPI), not... 0.5px ....selects, and the Alt Text field — all should show the samevar(--wp-admin-border-width-focus)ring (2px, 1.5px on HiDPI).Out of scope (raising as questions on the ticket)
These consistency items from the ticket need a design decision rather than a value swap, so they are intentionally left out of this PR:
media.css→.media-frame.mode-grid .attachment:focus, outset ring) and the editor's select-media modal (media-views.css→.wp-core-ui .attachment:focus, inset ring).Screenshots
Before -
Now -
Before -
Now -
Before -
After -
Use of AI
Claude Code Opus 4.8
Assisted with investigating the conflicting focus rules and drafting PR description; all changes were manually reviewed and tested before committing.