Skip to content

[a11y] Darken background color on switches#7658

Open
47hao wants to merge 4 commits intodevelopfrom
andrewzhao/darker-switch-background
Open

[a11y] Darken background color on switches#7658
47hao wants to merge 4 commits intodevelopfrom
andrewzhao/darker-switch-background

Conversation

@47hao
Copy link
Copy Markdown
Contributor

@47hao 47hao commented Nov 25, 2025

Changes

Darkened the background color of off-state switches to achieve a minimum contrast ratio of 3.26:1.

  • Changed light mode only
  • Text changed to white, since the new color contrasts with white
  • Inactive background color is #878F9B, with hover and active states darker.

Screenshots

Before:
image

After:

Screen.Recording.2025-11-25.at.5.26.41.PM.mov

@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented Nov 25, 2025

Generate changelog in packages/core/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Darken background color on switches

Check the box to generate changelog(s)

  • Generate changelog entry

@47hao 47hao force-pushed the andrewzhao/darker-switch-background branch from 4f7b40f to f925606 Compare November 25, 2025 15:41
@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented Nov 25, 2025

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

🐛 Fixes

  • Darken background color on switches (#7658)

@47hao 47hao requested a review from a team November 25, 2025 15:45
@47hao 47hao changed the title Darken background color on switches [a11y] Darken background color on switches Nov 25, 2025
@svc-palantir-github
Copy link
Copy Markdown

Update contrast ratio to 3.54+

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

$switch-background-color-hover: rgba($gray3, 0.4) !default;
$switch-background-color-active: rgba($gray3, 0.5) !default;
$switch-background-color-disabled: rgba($gray3, 0.15) !default;
$switch-background-color: rgba($gray1, 0.7) !default;
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.

It looks like the contrast ratio of $gray1 (#5F6B7C) at 70% opacity has only a 2.94:1 contrast ratio on a white background. Is that sufficient to meet this minimum contrast ratio requirement?

Copy link
Copy Markdown
Contributor Author

@47hao 47hao Nov 25, 2025

Choose a reason for hiding this comment

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

I wonder if it's overlaid on other colors? I measured #878F9B color picking from a screenshot 5F6B7CB3

Copy link
Copy Markdown
Contributor

@ggdouglas ggdouglas Nov 25, 2025

Choose a reason for hiding this comment

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

This is what I'm measuring as the background-color on .bp6-control-indicator (#5F6B7CB3, which is #5F6B7C) at 70% opacity)

Screenshot 2025-11-25 at 14 23 12@2x

If we want to get the effective color here considering the transparent color on a white background, the calculation would be something like:

R = (95 × 0.7) + (255 × 0.3) = 66.5 + 76.5 = 143
G = (107 × 0.7) + (255 × 0.3) = 74.9 + 76.5 = 151
B = (124 × 0.7) + (255 × 0.3) = 86.8 + 76.5 = 163

which equals #8F97A3

FWIW, I think the contrast checker tool already does this since #5F6B7CB3 and #8F97A3 return the same result for contrast ratio at 2.94:1.

@47hao 47hao force-pushed the andrewzhao/darker-switch-background branch 2 times, most recently from dd909b2 to 3bc23e4 Compare November 25, 2025 20:49
@svc-palantir-github
Copy link
Copy Markdown

Update contrast ratio to 3.54+

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link
Copy Markdown

Don't use opaque colors

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@ggdouglas
Copy link
Copy Markdown
Contributor

@ryannono can you do a pass on these color changes for design approval?

@ryannono
Copy link
Copy Markdown
Contributor

ryannono commented Dec 8, 2025

@ggdouglas @mm-wang I'd say we skip this one.

Reasoning behind it is I tested using this in a few UIs and it's just too visually heavy.

Additionally, I looked around and even un-styled libraries who's sole focus is accessibility like React Aria, Headless UI, Reka etc don't bother and achieve a color contrast ratio of ~1.2-1.6. Not to mention Apple's own toggle component on Mac OS and IOS both fail at around that ~1.2-1.6 range as well.

BLAB If the most strict and popular accessibility libs don't follow this I think there's reason for it and we should be pragmatic.

@ggdouglas ggdouglas removed their assignment Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants