Skip to content

Commit 2cbb2e4

Browse files
authored
fix(ui): improve dark-mode contrast for off-state toggles (#5825)
* fix(ui): improve dark-mode contrast for off-state toggles The default off-state track uses --border-strong (#c9d0da light / #46433c dark). In dark mode #46433c is only ~5% lighter than the --bg-subtle (#252321) panel behind it, making the toggle nearly invisible when off and users unsure of the control state. Bump the off-state track to #6b6862 with a subtle inset border, and add a thin outline to the white thumb so it stays visible against the (now lighter) track. On-state already uses --text (#e8e4dc) and is left unchanged. Applies to both .toggle-row (used by speaker-notes toggle in the deck tab) and .compact-toggle (used by SurfaceOptions toggles). Hover lift gives an additional interactive affordance. Fixes #5298 * fix(ui): fix two dark-mode toggle blocking issues from review Two correctness issues called out by mrcfps: 1. System dark theme never gets the contrast fix — the default "system" theme mode removes [data-theme] and falls back to @media prefers-color-scheme. Added a parallel block scoped to html:not([data-theme]) inside @media (prefers-color-scheme: dark). 2. Hover override wins over on-state — .compact-toggle:hover and .toggle-row:hover have higher specificity than .on variants, so hovering an ON toggle dropped its track from bright var(--text) to #75726c. Changed to :not(.on):hover so the hover lift only applies when off, leaving the on-state always bright. Both applied to both selector paths (explicit data-theme and system dark).
1 parent 4a6c2da commit 2cbb2e4

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

apps/web/src/styles/workspace/artifacts.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,6 +3426,58 @@
34263426
.compact-toggle.on .compact-toggle-switch { background: var(--text); }
34273427
.compact-toggle.on .compact-toggle-switch::after { transform: translateX(12px); }
34283428

3429+
/* Dark-mode visibility for off-state toggles (#5298).
3430+
The default off-state track uses --border-strong, which in dark mode is
3431+
#46433c — only ~5% lighter than the --bg-subtle (#252321) panel behind it.
3432+
That makes the toggle track nearly invisible when the control is off,
3433+
leaving users unsure whether the setting is enabled. Bump the off-state
3434+
track to a clearly lighter neutral and outline the thumb so the white
3435+
knob stays visible against the (now lighter) track. On-state already
3436+
used --text (#e8e4dc) which is high-contrast, so it is left alone.
3437+
3438+
Two selector paths needed because Open Design supports both explicit
3439+
[data-theme='dark'] AND system dark via @media prefers-color-scheme
3440+
(the default "system" theme removes data-theme and falls back on the
3441+
media query in tokens.css). */
3442+
3443+
/* --- Explicit dark theme --- */
3444+
[data-theme='dark'] .toggle-row-switch,
3445+
[data-theme='dark'] .compact-toggle-switch {
3446+
background: #6b6862;
3447+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
3448+
}
3449+
[data-theme='dark'] .toggle-row-switch::after,
3450+
[data-theme='dark'] .compact-toggle-switch::after {
3451+
box-shadow:
3452+
0 1px 2px rgba(0, 0, 0, 0.4),
3453+
0 0 0 1px rgba(0, 0, 0, 0.18);
3454+
}
3455+
/* Hover: only lift the track when off, or the on-state bright track gets
3456+
overridden by a higher-specificity hover rule. */
3457+
[data-theme='dark'] .compact-toggle:not(.on):hover .compact-toggle-switch,
3458+
[data-theme='dark'] .toggle-row:not(.on):hover .toggle-row-switch {
3459+
background: #75726c;
3460+
}
3461+
3462+
/* --- System dark theme (the default — no data-theme attr set) --- */
3463+
@media (prefers-color-scheme: dark) {
3464+
html:not([data-theme]) .toggle-row-switch,
3465+
html:not([data-theme]) .compact-toggle-switch {
3466+
background: #6b6862;
3467+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
3468+
}
3469+
html:not([data-theme]) .toggle-row-switch::after,
3470+
html:not([data-theme]) .compact-toggle-switch::after {
3471+
box-shadow:
3472+
0 1px 2px rgba(0, 0, 0, 0.4),
3473+
0 0 0 1px rgba(0, 0, 0, 0.18);
3474+
}
3475+
html:not([data-theme]) .compact-toggle:not(.on):hover .compact-toggle-switch,
3476+
html:not([data-theme]) .toggle-row:not(.on):hover .toggle-row-switch {
3477+
background: #75726c;
3478+
}
3479+
}
3480+
34293481
/* -------- Template picker (template tab) ---------------------------- */
34303482
.template-list {
34313483
display: flex;

0 commit comments

Comments
 (0)