fix: ClickStack switch checked-state color not applying theme tokens#2241
Conversation
Mantine's `Switch` component falls back to `theme.primaryColor` (yellow in the ClickStack theme) for its checked-state track. Other binary form controls in this theme — `Checkbox` and `Radio` — already remap to the ClickStack accent token via their respective CSS vars, so the visible inconsistency was the toggle rendering yellow while the adjacent checkbox/radio rendered black. Override `--switch-color` on `Switch.extend` to use the same `--click-global-color-accent-default` token, mirroring the existing Checkbox/Radio overrides. Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 72a61f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
PR Review
Otherwise ✅ no critical issues. The |
Deep Review✅ No critical issues found. 🟡 P2 -- recommended
🔵 P3 nitpicks (1)
Reviewers (8): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, kieran-typescript, previous-comments. Testing gaps:
|
E2E Test Results✅ All tests passed • 164 passed • 3 skipped • 1216s
Tests ran across 4 shards in parallel. |
Extends the prior `--switch-color` token fix to also remap the on-label text color and the thumb background when the Switch is checked. Mantine's `:checked + .track` rule hard-codes `--switch-text-color: var(--mantine-color-white)` and leaves the thumb at its `var(--mantine-color-white)` fallback, so on the yellow ClickStack accent in dark mode both render white-on-yellow with poor contrast. The Mantine `vars`/`styles` API on the root can't reach the `:checked + .track` cascade (it targets a sibling element), so add a global rule in `clickstack/_tokens.scss` scoped to the theme class. The selector keys off the input's `role="switch"` + `data-checked="true"` attributes (set by Mantine in `Switch.tsx`) to stay independent of auto-generated CSS module class names, and re-uses `--click-global-color-background-default`, which is already scheme-aware (dark in dark mode, white in light mode). Co-authored-by: Cursor <cursoragent@cursor.com>
|
Noticed an E2E test failure and re-ran it and it passed. I put up a PR to fix the flake independently - #2243 |
Summary
Mantine's
Switchcomponent falls back totheme.primaryColor(yellow in the ClickStack theme) for its checked-state track. Other binary form controls in this theme —CheckboxandRadio— already remap to the ClickStack accent token via their respective CSS vars, which is why the toggle visibly rendered yellow while an adjacent checkbox/radio rendered black on the same setting page.This adds a
Switch.extendoverride that mirrors the existingCheckbox/Radioblocks, remapping--switch-colortovar(--click-global-color-accent-default).--switch-coloris the documented Mantine v7+ CSS variable that controls the checked-state track background, so no additionalstylesoverrides are needed — the thumb color, focus ring, and disabled state all keep their default behavior.Where this is visible
Anywhere a
Switchis rendered under the ClickStack theme.Before / After
Scope
clickstack/mantineTheme.tsis changed.hyperdxtheme intentionally keepstheme.primaryColor(green) for its checked Switch — matching the existing behaviour of its un-overridden Checkbox and Radio.Test plan