From bef7ba8023d5ea9993c003ab430efaa5626e3eba Mon Sep 17 00:00:00 2001
From: christin <46345125+chrifro@users.noreply.github.com>
Date: Fri, 16 Oct 2026 11:20:06 +0200
Subject: [PATCH] fix(site): increase Switch off-state contrast to meet WCAG
1.4.11 (#30547)
The unchecked `Switch` track and its hover state did not reach the 3:1
non-text contrast required by WCAG 1.4.11 against the page or the thumb
in either theme (1.18:1 to 1.91:1 in dark, 1.15:1 to 1.48:1 in light).
This adds a `surface-control` token for the unchecked track (dark:
zinc-500 `#71717A`; light: `240 5% 57%` `#8C8C97`, the lightest zinc-hue
grey that keeps 3:1 against `surface-secondary`, so unchecked tracks
stay easy to tell apart from checked ones), and uses the existing
`surface-invert-secondary` for unchecked hover, matching checked hover.
Checked and disabled states are unchanged, and `surface-quaternary`
keeps its value, so nothing else in the app changes.
Fixes DEQ-406, DEQ-358, DEQ-391, DEQ-55
| State | Theme | Before | After |
|---|---|---|---|
| Off, rest | Dark |
|
|
| Off, hover | Dark |
|
|
| Off, rest | Light |
|
|
| Off, hover | Light |
|
|
Screenshots are from `/settings/notifications` in the running app.
Contrast measurements and decision log
Computed colors measured in the browser on `/settings/notifications` and
on the template builder (`step=module-settings`,
`#mod-vscode-desktop-open_recent`), identical on both:
| State | Theme | Track / thumb / behind | Track vs behind | Thumb vs
track |
|---|---|---|---|---|
| Off, rest | Dark | `#71717A` / `#09090B` / `#18181B` | 3.67:1 (was
1.70) | 4.12:1 (was 1.91) |
| Off, hover | Dark | `#A1A1AA` / `#09090B` / `#18181B` | 6.91:1 (was
1.18) | 7.76:1 (was 1.33) |
| Off, rest | Light | `#8C8C97` / `#FFFFFF` / `#F4F4F5` | 3.03:1 (was
1.34) | 3.33:1 (was 1.48) |
| Off, hover | Light | `#3F3F46` / `#FFFFFF` / `#F4F4F5` | 9.50:1 (was
1.15) | 10.44:1 (was 1.27) |
In light theme the unchecked track (`#8C8C97`) is 4.48:1 against the
checked track (`#27272A`); with zinc-500 it was only 3.08:1, which made
on and off hard to scan.
Alternatives considered:
- Change `surface-quaternary` globally to zinc-600 (dark) / zinc-400
(light): still under 3:1 for the switch (about 2.3 to 2.6:1), and drops
the Template Insights progress bar fill below 3:1 against its track.
- Use `surface-tertiary` for the off track: lowers contrast further and
matches the disabled state.
- Use `surface-invert-secondary` for the off track at rest: passes, but
makes rest and hover identical.
- zinc-500 in light theme: passes (4.40:1) but sits close to the checked
track. zinc-400 fails (2.33:1). No zinc step exists between them, so
light theme uses `240 5% 57%` (suggested in review); `240 4% 54%`
(3.33:1) was considered for extra margin.
- The value differs per theme and is role-based, so it gets its own
token rather than reusing a decorative surface token.
Frontend self-review (FE1 to FE10): pass. Existing `Switch` stories
(`DefaultOff`, `SmallOff`, disabled variants) cover the changed visual
states; there is no behavior change.
---
_Generated by Coder Agents on behalf of @chrifro._
---------
Co-authored-by: Andrew Aquino
---
site/src/components/Switch/Switch.tsx | 4 ++--
site/src/index.css | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/site/src/components/Switch/Switch.tsx b/site/src/components/Switch/Switch.tsx
index a5a390de019..13b57f7694e 100644
--- a/site/src/components/Switch/Switch.tsx
+++ b/site/src/components/Switch/Switch.tsx
@@ -13,8 +13,8 @@ const switchVariants = cva(
focus-visible:ring-offset-2 focus-visible:ring-offset-surface-primary
disabled:cursor-not-allowed
data-[state=checked]:disabled:bg-surface-tertiary data-[state=unchecked]:disabled:bg-surface-tertiary
- data-[state=checked]:hover:bg-surface-invert-secondary data-[state=unchecked]:hover:bg-surface-tertiary
- data-[state=checked]:bg-surface-invert-primary data-[state=unchecked]:bg-surface-quaternary`,
+ data-[state=checked]:hover:bg-surface-invert-secondary data-[state=unchecked]:hover:bg-surface-invert-secondary
+ data-[state=checked]:bg-surface-invert-primary data-[state=unchecked]:bg-surface-control`,
{
variants: {
size: {
diff --git a/site/src/index.css b/site/src/index.css
index 163660ecf8f..f89f9d50743 100644
--- a/site/src/index.css
+++ b/site/src/index.css
@@ -61,6 +61,7 @@
--color-surface-secondary: hsl(var(--surface-secondary));
--color-surface-tertiary: hsl(var(--surface-tertiary));
--color-surface-quaternary: hsl(var(--surface-quaternary));
+ --color-surface-control: hsl(var(--surface-control));
--color-surface-invert-primary: hsl(var(--surface-invert-primary));
--color-surface-invert-secondary: hsl(var(--surface-invert-secondary));
--color-surface-destructive: hsl(var(--surface-destructive));
@@ -445,6 +446,7 @@
--surface-secondary: 240 5% 96%;
--surface-tertiary: 240 6% 90%;
--surface-quaternary: 240 5% 84%;
+ --surface-control: 240 5% 57%;
--surface-invert-primary: 240 4% 16%;
--surface-invert-secondary: 240 5% 26%;
--surface-destructive: 0 93% 94%;
@@ -528,6 +530,7 @@
--surface-secondary: 240 6% 10%;
--surface-tertiary: 240 4% 16%;
--surface-quaternary: 240 5% 26%;
+ --surface-control: 240 4% 46%;
--surface-invert-primary: 240 6% 90%;
--surface-invert-secondary: 240 5% 65%;
--surface-destructive: 0 75% 15%;