New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MatSelect: poor contrast ratios with some dark mode color palettes #15672
Comments
Dang it, I knew this all sounded really familiar, and when I went to add a workaround in my styles I found a comment that pointed me to #13905 . I guess there are two components that use primary color where contrast is supposed to be :-/ |
+1 Started writing an issue before finding this one. Repro: https://stackblitz.com/edit/components-issue-dpd35z Screenshot showing Chrome doesn't approve of the contrast ratio: |
On the snackbar issue, I linked to the spec guidance on colors in dark themes. It's very helpful and talks about using primary / accent for text. Basically, you use very light tones (50/100/200) when picking text. It looks like #15149 was recently merged and adds a separate |
#15148 was just locked by the auto-close bot, but remains relevant here. If there were some way to have palettes default to a high-value hue for |
The color contrast issue for selected option is reproducible not only for dark theme, but for Blue one as well. |
What is the expected behavior?
Text colors should be chosen consistently to have good contrast with application background.
What is the current behavior?
The selected option in the dropdown of a
mat-select
uses the theme's primary color as text color.What are the steps to reproduce?
Open any (non-customized) select control on the docs page. Change the demo site's themes and observe that the selected item's text color matches the app bar.
For the Blue light theme, it is difficult to tell the primary color (dark blue) from the non-selected items (black). Worse, with the purple dark theme, there is little contrast between the purple primary color and the light gray option-list background.
This contrast calculation shows a contrast ratio of about 1.5; the spec requires compliance with accessibility guidelines including contrast of 4.5.
Is there anything else we should know?
I'm not positive how to best solve this. I went looking for a spec to consult but I can't seem to find any description of a Select component in the current Material documentation, so there's no guidance about what color to "pick" for showing selected state. Ideally you'd always use a text color that's defined as
contrast
in a palette. Maybe selection state should be conveyed by text weight instead of changing color? As far as I can tell, themat-select
is the only component that usesprimary
as a text color (instead of a control or block/background color).You could tell designers to always pick a primary that contrasts well with the theme background (light/dark) but this would pretty severely limit the available colors we can use and invalidates a lot of the popular themes, including some of the default ones.
The text was updated successfully, but these errors were encountered: