Skip to content

Base styles: Allow overriding focus ring color in outset-ring__focus - #80587

Merged
mirka merged 4 commits into
trunkfrom
base-styles/outset-ring-focus-color-override
Jul 23, 2026
Merged

Base styles: Allow overriding focus ring color in outset-ring__focus#80587
mirka merged 4 commits into
trunkfrom
base-styles/outset-ring-focus-color-override

Conversation

@mirka

@mirka mirka commented Jul 22, 2026

Copy link
Copy Markdown
Member

Extracted from #80417

What?

Updates outset-ring__focus to expose the focus ring color through a --focus-color custom property, defaulting to --wpds-color-stroke-focus.

Why?

Several legacy form controls need to align their focus rings with the design system, and some validated controls need to override the ring color. Moving the color into a custom property lets consumers override it without redefining the whole mixin.

For consumers, this is safer than overriding with outline-color, and also avoids specificity issues.

How?

  • Set --focus-color inside outset-ring__focus, defaulting to the WPDS focus stroke token.
  • Use var(--focus-color) for the outline color.

Testing Instructions

No user-facing behavior changes unless a consumer sets --focus-color.

@mirka mirka self-assigned this Jul 22, 2026
@github-actions github-actions Bot added the [Package] Base styles /packages/base-styles label Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Size Change: +95 B (0%)

Total Size: 7.75 MB

📦 View Changed
Filename Size Change
build/scripts/components/index.min.js 273 kB +3 B (0%)
build/styles/block-editor/style-rtl.css 20 kB +7 B (+0.04%)
build/styles/block-editor/style-rtl.min.css 17 kB +8 B (+0.05%)
build/styles/block-editor/style.css 20 kB +15 B (+0.08%)
build/styles/block-editor/style.min.css 17 kB +8 B (+0.05%)
build/styles/components/style-rtl.css 18.1 kB +13 B (+0.07%)
build/styles/components/style-rtl.min.css 15 kB +14 B (+0.09%)
build/styles/components/style.css 18.2 kB +13 B (+0.07%)
build/styles/components/style.min.css 15 kB +14 B (+0.09%)

compressed-size-action

@mirka mirka added the [Type] Enhancement A suggestion for improvement. label Jul 22, 2026
@mirka
mirka marked this pull request as ready for review July 22, 2026 18:51
@mirka
mirka requested a review from a team July 22, 2026 18:51
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@aduth

aduth commented Jul 22, 2026

Copy link
Copy Markdown
Member

I suppose the advantage of this approach over optional Sass mixin argument is that the mixin can be included once and the outline color contextually controlled in e.g. class modifiers?

@aduth

aduth commented Jul 22, 2026

Copy link
Copy Markdown
Member

Would overriding --wpds-color-stroke-focus be the wrong way for someone to extend this? 🙂

@aduth

aduth commented Jul 22, 2026

Copy link
Copy Markdown
Member

Should we extend this capability to the @wordpress/ui focus utilities?

@aduth aduth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mirka

mirka commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

I suppose the advantage of this approach over optional Sass mixin argument is that the mixin can be included once and the outline color contextually controlled in e.g. class modifiers?

Right. I think this is going to match a consumer's mental model better, since a mixin argument feels very static. Changing the focus ring color is more like a state-based operation.

.my-field:focus {
  @include mixins.outset-ring__focus();

  &:invalid {
    --focus-color: red;
  }
}

versus

.my-field:focus {
  &:not(:invalid) {
    @include mixins.outset-ring__focus();
  }

  &:invalid {
    @include mixins.outset-ring__focus(red);
  }
}

@mirka

mirka commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

Would overriding --wpds-color-stroke-focus be the wrong way for someone to extend this? 🙂

We literally have a lint rule to prevent overriding tokens directly 😄

@mirka

mirka commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

Should we extend this capability to the @wordpress/ui focus utilities?

Yes, and probably by depending on the base-styles mixin.

@mirka
mirka merged commit 60795eb into trunk Jul 23, 2026
47 checks passed
@mirka
mirka deleted the base-styles/outset-ring-focus-color-override branch July 23, 2026 14:30
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 23, 2026
@mirka

mirka commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

Should we extend this capability to the @wordpress/ui focus utilities?

Follow up in #80635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Base styles /packages/base-styles [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants