Skip to content

Switch, FormToggle: Light thumb with sliding 1 and 0 track labels - #86678

Merged
jameskoster merged 9 commits into
trunkfrom
update/switch-checkmark-knob
Nov 18, 2026
Merged

jameskoster merged 9 commits into
trunkfrom
update/switch-checkmark-knob

Conversation

@jameskoster

@jameskoster jameskoster commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #86259

Restyles Switch (@wordpress/ui) and FormToggle (@wordpress/components) following the concept in #86259. The knob is a light, bordered pill in every enabled state, and the track shows a small 1 when the switch is on and a 0 when it's off. The labels show in the disabled states too. Follows #86584, which moved progress and meter fills onto new indicator tokens so the thumb tokens could be used for the switch knob.

Why?

A disabled switch that's on looks almost the same as one that's off, because "on" is only communicated by the track color and the knob position. The labels make the state readable without relying on color or position (WCAG 1.4.1 Use of Color).

The labels sit on the track rather than in the knob, so the knob's content doesn't change mid-slide. The track behaves like a single surface split between the brand color and the neutral color: the brand fill and the labels slide with the knob, so toggling changes position rather than color. That makes the animation smoother and better preserves the physical metaphor of a switch.

Earlier iterations

This PR first put a check mark in the knob, then tried iOS-style 1 and 0 labels on the track. Joen suggested keeping the labels on the track but using a tiny, thin check and cross, so they read clearly while still feeling like part of the background. After trying that, the PR is back to 1 and 0. The labels first faded in and out under the knob; they now slide with it. FormToggle had I/O indicators on the track until #23202 removed them in 2020; the problem they didn't solve then, the disabled state, is the focus here.

How?

Tokens (@wordpress/theme):

  • --wpds-color-background-thumb-neutral is repurposed as the knob color of a switch that's off. It's now a light color in light and dark themes alike, where it was previously dark. This is listed as a breaking change in the changelog; progressbar and meter fills already moved to --wpds-color-background-indicator-neutral in Theme: Add indicator color tokens for progressbar and meter fills #86584.
  • New --wpds-color-background-thumb-neutral-disabled for disabled knobs. It follows the theme, so disabled knobs are dark in dark mode.
  • New --wpds-color-background-thumb-brand-strong for the knob of a switch that's on. It's the inverse of the brand fill, so it stays light against the on track.
  • New --wpds-color-background-track-neutral-disabled for disabled tracks. --wpds-color-background-track-neutral's description now mentions switch tracks.

Components:

  • The track uses --wpds-color-background-track-neutral, which keeps it distinct from the light knob. The brand fill (background-interactive-brand-strong) is a panel inside the track whose edge always sits under the middle of the knob. It slides with the knob, so the knob always covers the seam and the track never fades between colors. The track border turns brand when on.
  • The knob spans the full 16px height and covers the track border. It's 20px wide, a pill rather than a circle; I'm not tied to the pill shape if there's objection. Its border is stroke-interactive-neutral when off and stroke-interactive-brand when on.
  • The 1 and 0 are small custom SVGs, 8px square with a 1px stroke, centered in the part of the track the knob leaves exposed. They slide with the knob: as one slides in from the track's edge, the other slides out and is clipped. The 1 uses foreground-interactive-brand-strong (already a contrast pair with the brand fill) and always sits on the brand fill; the 0 uses foreground-interactive-neutral-weak and always sits on the neutral track. Disabled labels use foreground-interactive-neutral-disabled.
  • The brand panel and the labels sit in their own layer over the track. It covers the track border and clips at the track's outer edge, so the panel's rounded edge doesn't leave a pale ring inside the on track. In FormToggle this is a new components-form-toggle__labels element after the track.
  • The knob, brand panel and labels move by animating inset-inline-start and inset-inline-end rather than a translateX, with the same duration and easing, so they stay in step and follow the writing direction without a separate RTL rule.
  • Disabled switches hide the brand panel and use the same track and border whether they're on or off, so the labels and the knob position are what show the state.
  • Forced colors: the knob uses Canvas with a CanvasText border (Highlight when on), the brand panel and the on track border use Highlight, the labels use HighlightText and CanvasText, and disabled parts use GrayText.
  • FormToggle mirrors Switch. The old transparent-border trick for high contrast mode is replaced by the explicit forced-colors rules.
  • FormToggle's checked and hover styles now follow the input's :checked state rather than the checked prop, so an uncontrolled ToggleControl (no checked passed) shows the right state. Previously its knob didn't move either; the labels made that more obvious.

Known issue: light brand colors

With a pale brand color (yellow, for example), thumb-brand-strong resolves to a dark color, so the on knob goes dark. A solution could be to use colors from the neutral scale for the knob in both the on and off states (as I mentioned in #86259 (comment)), but that would be a larger visual change, so I've left it out of this PR for now.

Follow-up

A hover treatment for checked controls (Switch, Checkbox, Radio and their @wordpress/components counterparts) is planned as a follow-up, so they stay consistent with each other.

Testing Instructions

  1. Run npm run storybook:dev.
  2. Open the Switch, SwitchControl, FormToggle and ToggleControl stories.
  3. Check the off, on, disabled off and disabled on states. The 1 shows only when on, the 0 only when off, and the disabled states share the same track.
  4. Toggle an enabled switch: the brand fill and the labels slide with the knob, and the track doesn't fade between colors.
  5. Hover an enabled off switch: the track and knob borders darken.
  6. Switch the Storybook theme to dark and confirm the knob stays light and the labels stay legible.
  7. Emulate forced colors (DevTools, Rendering, forced-colors: active) and confirm the knob and labels stay visible in all four states.
  8. With the Storybook RTL setting, confirm the knob moves to the left when on, the brand fill grows from the right, and the knob doesn't cover the 1.
  9. Render a ToggleControl without checked and toggle it: the track, knob and labels update.

Testing Instructions for Keyboard

  1. Tab to a switch: the focus ring shows on the track.
  2. Press Space to toggle it: the knob slides across, and the brand fill and labels slide with it.

Screenshots or screencast

switch-dark switch-light

Use of AI Tools

Written with Cursor (Claude) and Claude Code, and reviewed by me.

🤖 Generated with Claude Code

@jameskoster
jameskoster requested a review from a team as a code owner November 11, 2026 14:00
@jameskoster jameskoster added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components [Package] Base styles /packages/base-styles Design System Issues related to the system of combining components according to best practices. [Package] Theme /packages/theme [Package] UI /packages/ui labels Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: yaman-694 <yamanzyan@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: JanaMW27 <janahernandezaraujo@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +1.74 kB (+0.02%)

Total Size: 8.67 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 556 kB +624 B (+0.11%)
build/scripts/components/index.min.js 338 kB +126 B (+0.04%)
build/scripts/theme/index.min.js 27.1 kB +23 B (+0.08%)
build/styles/components/style-rtl.css 18.3 kB +195 B (+1.08%)
build/styles/components/style-rtl.min.css 15.4 kB +219 B (+1.44%)
build/styles/components/style.css 18.4 kB +198 B (+1.09%)
build/styles/components/style.min.css 15.4 kB +213 B (+1.4%)
build/styles/theme/design-tokens-rtl.css 3.31 kB +54 B (+1.66%)
build/styles/theme/design-tokens-rtl.min.css 1.57 kB +15 B (+0.96%)
build/styles/theme/design-tokens.css 3.31 kB +54 B (+1.66%)
build/styles/theme/design-tokens.min.css 1.57 kB +15 B (+0.96%)

796eace Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric da91622 trunk % Change
timeToFirstByte 48.15 ms +5.5% -3.32% 47.65 ms +6.61% -3.88% 1.05%
largestContentfulPaint 76 ms +7.89% -2.63% 76 ms +10.53% -0% 0%
lcpMinusTtfb 27.4 ms +8.21% -2.55% 28.85 ms +4.33% -3.47% -5.03%
wpBeforeTemplate 23.99 ms +5.29% -1.33% 23.91 ms +6.52% -3.6% 0.33%
wpTemplate 20.15 ms +3.03% -4.91% 19.84 ms +3.13% -2.12% 1.56%
wpTotal 44.36 ms +5.93% -3.2% 43.97 ms +6.44% -4.16% 0.89%
wpMemoryUsage 7.75 MB +0% -0% 7.71 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric da91622 trunk % Change
timeToFirstByte 39.5 ms +3.04% -2.03% 40.6 ms +3.69% -1.72% -2.71%
largestContentfulPaint 76 ms +0% -2.63% 76 ms +0% -5.26% 0%
lcpMinusTtfb 36.1 ms +1.8% -6.09% 33.55 ms +5.51% -4.32% 7.6%
wpBeforeTemplate 21.21 ms +1.04% -1.08% 21.73 ms +4.46% -1.47% -2.39%
wpTemplate 14.96 ms +4.28% -1.94% 15.47 ms +4.07% -2.71% -3.3%
wpTotal 36.48 ms +3.1% -2.03% 37.47 ms +4.14% -1.33% -2.64%
wpMemoryUsage 6.44 MB +0% -0% 6.40 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric da91622 trunk % Change
mediaProcessingJpeg 412.39 ms +1.46% -0.33% 411.79 ms +0.56% -0.29% 0.15%
mediaProcessingAvif 6346.8 ms +0.25% -0.28% 6342.54 ms +0.12% -0.1% 0.07%
mediaProcessingJpegToAvif 4354.22 ms +0.59% -0.22% 4370.15 ms +0.26% -0.39% -0.36%

media-upload

Metric da91622 trunk % Change
jpegUploadProcessing 1511.57 ms +33.85% -0.99% 1492.87 ms +1.52% -0.83% 1.25%
pngUploadProcessing 262.68 ms +4.17% -1.51% 253.21 ms +0.86% -4.27% 3.74%
largeJpegUploadProcessing 1506.4 ms +2.95% -0.83% 1473.34 ms +0.41% -0.21% 2.24%
multipleImageUploadProcessing 1687.64 ms +22.04% -1.05% 1644.31 ms +7.14% -0.6% 2.64%

post-editor

Metric da91622 trunk % Change
serverResponse 259.49 ms +7.16% -4.77% 230.58 ms +7.84% -3.18% 12.54%
firstPaint 292.19 ms +6.66% -5.36% 276.05 ms +2.62% -14.16% 5.85%
domContentLoaded 555.88 ms +4.24% -1.36% 488.68 ms +0.63% -2.14% 13.75%
loaded 557.16 ms +4.17% -1.44% 489.35 ms +0.69% -2.07% 13.86%
firstContentfulPaint 315.29 ms +6.49% -3.4% 282.36 ms +1.87% -2.39% 11.66%
firstBlock 1461.52 ms +3.59% -1.19% 1296.58 ms +1.11% -0.23% 12.72%
type 12.59 ms +8.58% -10.48% 11.27 ms +8.25% -6.83% 11.71%
typeWithoutInspector 13.42 ms +5.81% -6.41% 12.23 ms +3.43% -12.67% 9.73%
typeWithTopToolbar 16.45 ms +7.29% -2.92% 16.35 ms +12.66% -4.22% 0.61%
typeContainer 6.27 ms +1.91% -8.61% 6 ms +2.17% -14.17% 4.5%
focus 71.06 ms +3.98% -3.49% 69.29 ms +5.35% -7.2% 2.55%
firstFocus 162 ms +0% -0% 161.29 ms +0% -0% 0.44%
selectAll 244.83 ms +3.68% -1.73% 230.11 ms +2.32% -2.33% 6.4%
undo 19.66 ms +6.51% -2.85% 18.8 ms +4.84% -3.78% 4.57%
listViewOpen 48.43 ms +13.9% -8.57% 44.36 ms +9.6% -9.63% 9.17%
inserterOpen 26.99 ms +9.23% -6.11% 27.69 ms +6.36% -5.92% -2.53%
inserterHover 7.69 ms +8.58% -3.25% 8.17 ms +6.61% -6.49% -5.88%
inserterSearch 6.47 ms +4.95% -4.95% 6.12 ms +7.84% -2.94% 5.72%
loadPatterns 403.63 ms +2.77% -5.7% 416.26 ms +8.13% -4.07% -3.03%
wpTotal 252.61 ms +7.26% -4.87% 223.53 ms +8.27% -3.03% 13.01%
wpMemoryUsage 14.81 MB +0% -0% 14.77 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric da91622 trunk % Change
serverResponse 274.42 ms +1.77% -1.14% 274.48 ms +2.26% -6.68% -0.02%
firstPaint 295.57 ms +11.91% -5.38% 288 ms +14.54% -6.56% 2.63%
domContentLoaded 588.35 ms +1% -1.3% 578.52 ms +1.72% -1% 1.7%
loaded 589.27 ms +1% -1.31% 579.37 ms +1.72% -1% 1.71%
firstContentfulPaint 331.59 ms +3.52% -0.6% 330.24 ms +1.6% -1.95% 0.41%
firstBlock 1819.5 ms +1.02% -2.42% 1797.33 ms +1.37% -1.24% 1.23%
type 13.14 ms +14.46% -6.85% 14.16 ms +6.36% -9.11% -7.2%
navigate 87.83 ms +15.84% -4.18% 85.71 ms +11.29% -7.58% 2.47%
loadPatterns 1014.44 ms +7.03% -0.83% 1040.07 ms +4.43% -2.19% -2.46%
loadPages 955.21 ms +3.16% -1.74% 960.73 ms +1.87% -3.48% -0.57%
wpTotal 267.65 ms +1.74% -1.18% 267.62 ms +2.32% -6.89% 0.01%
wpMemoryUsage 12.82 MB +0% -0% 12.79 MB +0% -0% 0.25%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

796eace Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 6,
+   "offset": 6,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
Undo restores the post selection when another synced entity is loaded in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 6,
+   "offset": 6,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 2 failed attempts.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should reset a named font size using input field in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"small"} -->
+ <!-- wp:paragraph {"fontSize":"tiny"} -->
- <p class="has-small-font-size">Paragraph with font size reset using input field</p>
+ <p class="has-tiny-font-size">Paragraph with font size reset using input field</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:216:6
should select synced pattern in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]') with timeout 5000ms
  - waiting for locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
    14 × locator resolved to <div tabindex="0" role="document" draggable="true" data-title="Pattern" data-type="core/block" data-is-drop-zone="true" aria-label="Block: Pattern" id="block-cc05790b-91b1-4fc4-8971-a7a6beaeab5c" data-block="cc05790b-91b1-4fc4-8971-a7a6beaeab5c" class="block-editor-block-list__block wp-block is-selected is-reusable block-library-block__reusable-block-container wp-block-block block-editor-block-list__layout">…</div>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:1464:5

796eace Run

@ciampo ciampo self-assigned this Nov 11, 2026
Comment thread packages/theme/CHANGELOG.md Outdated

- `--wpds-color-background-thumb-neutral` and `--wpds-color-background-thumb-brand` are now only for the movable handle of a control, such as a slider handle or scrollbar thumb. For the filled portion of a progressbar or meter, use `--wpds-color-background-indicator-neutral` and `--wpds-color-background-indicator-brand` instead. `--wpds-color-background-thumb-neutral` will change to a light color for switch knobs in a future release ([#86584](https://github.com/WordPress/gutenberg/pull/86584)).
- `--wpds-color-background-thumb-neutral` and `--wpds-color-background-thumb-brand` are now only for the movable handle of a control, such as a slider handle or scrollbar thumb. For the filled portion of a progressbar or meter, use `--wpds-color-background-indicator-neutral` and `--wpds-color-background-indicator-brand` instead ([#86584](https://github.com/WordPress/gutenberg/pull/86584)).
- `--wpds-color-background-thumb-neutral` is now a light color for switch knobs, where it was previously dark. Anything still using it for a progressbar or meter fill should move to `--wpds-color-background-indicator-neutral` ([#86678](https://github.com/WordPress/gutenberg/pull/86678)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since @wordpress/theme is externalised, and @wordpress/ui is bundled, this means that an older version of @wordpress/ui rendered in a newer version of @wordpress/theme will render components like Progress with a lighter color, which won't pass accessibility criteria.

@WordPress/gutenberg-components not sure if this is a blocker for this approach.

(Sidenote: also, is it ok that --wpds-color-background-thumb-neutral is lighter than --wpds-color-background-thumb-neutral-weak?)

@jameskoster
jameskoster marked this pull request as draft November 11, 2026 14:58
@jameskoster

Copy link
Copy Markdown
Contributor Author

Marking as a draft while I tweak a few details.

@jameskoster
jameskoster marked this pull request as ready for review November 11, 2026 15:57
@jasmussen

Copy link
Copy Markdown
Contributor

This is really tricky, man. I like that it sits on the track so in theory it doesn't break "physics", insofar as the indicators can be always there but covered by the knob. But there's something about those 1/0's, that although meant to be universal, doesn't read well for me in this implementation, even if it's a very competent one.

Not sure if it helps, but here's another implementation I saw recently:

Skærmbillede 2026-11-12 kl  14 08 37 Skærmbillede 2026-11-12 kl  14 08 44

In the above, I like that the check and cross are tiny, and thin stroke, so they truly feel backgroundy.

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In my testing, when I omit checked from ToggleControl and press Space, onChange receives true but the track still shows 0. Could we use the input's :checked state for the labels, thumb, and track so the visual state follows the checkbox in both controlled and uncontrolled use?

Also, in the built Storybook's RTL setting, the checked thumb extends past the track and covers the 1. Could we animate inset-inline-start so the thumb follows the same direction as the labels?

@ciampo

ciampo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Code changes LGTM, although the compat issue that I flagged previously is still present; not sure if we can do much about it, though.

@jameskoster

Copy link
Copy Markdown
Contributor Author

@jasmussen I pushed a version that uses a cross/checkmark. What do you think?

@jasmussen

Copy link
Copy Markdown
Contributor

For me, this is the key screen to review:

2026-11-16 08 10 36 localhost af0b239cff60

And it's not terrible. It's not as bad as I had worried, insofar as the duplicated symbols could end up adding a lot of noise.

The knob is no longer pure white. Can it be? Is there a "strong" variant that makes it light up more? And can this work if the check is the ONLY symbol, that we remove the cross? Neither of these are strong feelings, but they are instincts. I'd love a last quick look from @WordPress/gutenberg-design, and from @JanaMW27. But otherwise, I think we can try this.


One completely unrelated thing, and while I'm in preferences:

image

I don't think the left border works. I recognise the desire to make tabs look alike with just a directional change, but I think the previous vertical tabs read better, and lined up better.

@jasmussen

Copy link
Copy Markdown
Contributor

Just seen from GH:

state

I still think the I/O aren't quite as clear as the check and cross, but there's a nice animation that actually explains why the truth to materials (symbols on the track getting "pulled in"/revealed) is meaningful.

@ciampo

ciampo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

I don't think the left border works. I recognise the desire to make tabs look alike with just a directional change, but I think the previous vertical tabs read better, and lined up better.

Previously we were using a background color to indicate vertically selected tabs, but that treatment was odd compared to how other interactive button-like DS ui works. Therefore, for consistency reasons, we made changes in #84572 and #84821:

  • the background color change is used for hover/focus states, both for horizontal and vertical tabs
  • the indicator is used for marking the selected tabs, in vertical tabs too

This is all related to how our "neutral" text tokens can't really get darker on hover/focus (since they're quite dark already in their "resting" state), and how therefore we need a different visual clue to give feedback about hover/focus (see previous conversations in #77153, #81088 (comment), and the work being done in #82294)

In other words, if we switched back to using background for selected vertical tabs, we'd lose a way to highlight the selected tab on hover, and I'm not sure we'd have a way to differentiate between a hovered, non-selected tab, and a selected tab. Also, we may actually need to rethink the background anyway, in case the indication for the selected tab needs to meet a minimum contrast threshold.

@hanneslsm

hanneslsm commented Nov 16, 2026 •

Copy link
Copy Markdown

Not sure if it helps, but here's another implementation I saw recently:

Let us please not put the X and ✓ in the toggle, as it's very confusing.
Right is always on, left is always off. However, putting the checkmark on the left, fights with this hierarchy. Why should a label for on be on the left, when on is on the right?
This issue exited already in the early versions of iOS. Here is a comment on Stack Overflow, from 13 years ago: https://ux.stackexchange.com/a/40954

The best solution in my opinion is as @jasmussen already saw on Github: adding an indicator besides the switch. It also reduces the visual noise. I also agree that the IO analogy is not clear, and I doubt that it is really needed.

@jasmussen

Copy link
Copy Markdown
Contributor

Just to respond to Marco, yes your feedback on the tabs is valid enough, and certainly separate. For me the solution is simple: show a very light active highlight, and just bold the text when it's active, the bold text is the shape change that means the backdrop doesn't have to meet 3:1 contrast. Or add a chevron, or something else. I also understand this makes the vertical tabs visually separate fro horizontal tabs, which I suspect is where the motivation for the change came from. GitHub, to use an example again, has horizontal tabs-like navigation for repos, and vertical tabs in the settings pages. They do have a vertical border there, but it would work even without the vertical border. So for me, the fact that vertical and horizontal tabs look different, that doesn't matter too much to me. But I think I can try a POC PR to explain what i mean.

@jameskoster

jameskoster commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

adding an indicator besides the switch.

@hanneslsm That suggestion won't work for things like SwitchControl because the indicator will clash with the actual label. If we were going to do that I'd prefer to just have a toggle button where the label swaps between "Turn on"/"Turn off".

iOS has on/off indicators btw, albeit behind an accessibility option. It follows the design proposed here.

@github-actions
github-actions Bot requested review from aduth and ciampo November 16, 2026 10:46
@jameskoster

Copy link
Copy Markdown
Contributor Author
Screen.Recording.2026-11-16.at.10.45.25.mov

@jasmussen I pushed a version where check mark and cross now look like they’re printed on a strip that slides with the knob rather than the knob sliding over the track.

@jasmussen

Copy link
Copy Markdown
Contributor

I quite like that animation. And while I like the cross and check still, I ultimately defer to Jana, and I also want to note that Hannes' feedback is valid too. Anything stand out as something we want to try?

@jameskoster

Copy link
Copy Markdown
Contributor Author

Jana is away for 3 months so hopefully we can make a decision amongst ourselves.

Hannes' feedback

Which part?

@hanneslsm

Copy link
Copy Markdown

That suggestion won't work for things like SwitchControl because the indicator will clash with the actual label.

Okay. But then, I'd suggest using the design as proposed in #86259 (comment) aka putting the checkmark on the knob, instead of the track. As said, I find it confusing that a label/indicator on the track sits on the wrong side.

@jameskoster

Copy link
Copy Markdown
Contributor Author

@hanneslsm placing the indicator on the track seems to be the prevailing convention (see iOS, GitHub, etc.). I'm not married to it though. If there's consensus to put the indicator on the knob that's fine with me but it seems a bit unclear.

If you twisted my arm I'd argue:

  • If we're putting the indicators on the track we should use the 1/0 convention.
  • If we're putting the indicators on the knob then the check mark works better.

I don't mind either way, both fix the reported issue :) These seem like details we can easily revisit later...

@hanneslsm

Copy link
Copy Markdown

If you twisted my arm I'd argue:
If we're putting the indicators on the track we should use the 1/0 convention.
If we're putting the indicators on the knob then the check mark works better.

Yes, I like that!

@jasmussen

Copy link
Copy Markdown
Contributor

Yep, that part. cross or check, or 1/0, or nothing.

I still prefer anything we put on the track, because it "obeys the laws of nature", as visible by the nice little animation. But none of this I feel strongly about, so I defer to you and Jana.

@jameskoster jameskoster changed the title Switch, FormToggle: Light thumb with a check mark when on Switch, FormToggle: Light thumb with sliding 1 and 0 track labels Nov 16, 2026
@jameskoster

jameskoster commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Pushed an update to restore the 1/0.

Screen.Recording.2026-11-16.at.13.19.41.mov

@jameskoster
jameskoster force-pushed the update/switch-checkmark-knob branch 2 times, most recently from d80acf0 to 5982fef Compare November 16, 2026 14:08
@ciampo

ciampo commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Code changes LGTM, although the compat issue that I flagged previously is still present; not sure if we can do much about it, though.

Gave another look, code continues to LGTM . Looks like we reached design consensus, too.

The last item to evaluate is the compat issue listed above (cc @WordPress/gutenberg-components ). Given that the issue doesn't feel critical, and can be solved by updating the bundled copy of @wordpress/ui, I'm going to approve the PR.

Let's give folks a little bit more time in case they wanted to share thoughts on the topic.

jameskoster and others added 9 commits November 17, 2026 14:55
Repurpose --wpds-color-background-thumb-neutral as a light switch knob and
add --wpds-color-background-thumb-neutral-disabled. Both switches now use the
neutral-weak track when off, a full-height bordered thumb, and show the
checkbox check mark in the thumb when on, including when disabled.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…from the off track

- Split the knob tokens: `background-thumb-neutral` (off) now maps to the neutral `bg.fgFillDark`, and the new `background-thumb-brand-strong` and `foreground-thumb-brand-strong` color the on knob and its check as the inverse of the brand fill.
- Move the off track to `track-neutral` and rename the disabled track token to `track-neutral-disabled`.
- Restore the brand stroke on the on knob.

Co-authored-by: Cursor <cursoragent@cursor.com>
… track

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…the knob

Co-authored-by: Cursor <cursoragent@cursor.com>
Instead of the knob sliding over the label that doesn't apply, the check
mark and cross now move with the knob: the label for the new state slides
in from the track edge as the other slides out, clipped by the track.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bring back the 1 and 0 track labels. Instead of the track changing color,
a brand panel now slides with the thumb, which always covers the edge where
it meets the neutral half. Each label stays on the same color, so the
outgoing label no longer shows grey on the brand track mid-animation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clipping the panel inside the track border left a faint pale ring inside
the on track, where the panel's anti-aliased rounded edge met the neutral
track. The panel and labels now sit in a layer that covers the border, so
the panel's edge meets the page instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jameskoster
jameskoster force-pushed the update/switch-checkmark-knob branch from 5982fef to 796eace Compare November 17, 2026 14:57
@jameskoster

Copy link
Copy Markdown
Contributor Author

We seem to have general agreement on this so I'm going to merge. Happy to follow up with any tweaks, or to add a token to allow consumer to make the 'labels' optional.

@jameskoster
jameskoster merged commit 035aa2f into trunk Nov 18, 2026
87 checks passed
@jameskoster
jameskoster deleted the update/switch-checkmark-knob branch November 18, 2026 15:42
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 18, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…rdPress#86678)

Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: yaman-694 <yamanzyan@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: JanaMW27 <janahernandezaraujo@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Design System Issues related to the system of combining components according to best practices. [Package] Base styles /packages/base-styles [Package] Components /packages/components [Package] Theme /packages/theme [Package] UI /packages/ui [Type] Enhancement A suggestion for improvement.

Projects

Status: 💫 Done

Development

Successfully merging this pull request may close these issues.

Disabled switch: "on" looks like "off" since #83773

4 participants