-
Notifications
You must be signed in to change notification settings - Fork 649
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
[css-color-5] limited use of contrast adjuster #1627
Comments
On second thought, maybe it would be better to split this into two adjusters:
Note that |
I agree that these are both important use cases. In general, I think the current proposal (and @xi's suggested fixes, too) suffers from trying to fit into the Would there really be any use case for fixing the contrast and then adding additional adjustments in the sequence? If not, maybe it is best to use a separate function altogether, which clearly takes separate arguments for the base color and the desired color (or colors) to test against it & modify if the contrast requirement isn't met. Adding the comment I made as a tangent to #1628 (sorry for muddling the discussion):
Her main |
The Material component library has a Sass mixin allowing to select an accessible ink color, to have enough contrast with the provided background. but it will always return one of 2 possible colors: A use case here is of course that the background color comes from a CSS custom property, to allow building a theming system. Currently, building such theming would still require having 2 initial CSS files (one for dark themes and one for light themes), and choosing the right one based on the theme color, as things cannot be computed in the browser. |
Closing since the contrast adjuster is no longer part of the spec. |
Usecase 1 has been addressed in the draft for css-color-5 |
Re-targetting to CSS Color 5, which has a contrast function |
Closing once more since color candidates now are part of the |
https://drafts.csswg.org/css-color-4/#contrast-adjuster
Usecase 1: My website uses
background-color: #ddd
andcolor: #333
. I want to add a button with a blue background and one of these colors for font. If none of these colors has enough contrast, it is ok to automatically pick a different one. - currently it is not possible to pick colors from an existing color scheme.Usecase 2: I want to have a green button with blue font. The font color should be automatically adjusted to guarantee sufficient contrast. - currently it is not possible to have a different hue than the base color.
Both these use cases could be catered for with an extension like this:
contrast( <color1>?, <color2>?, <color3>?, …, <percentage>? )'
See my gist for a working Sass implementation.
The text was updated successfully, but these errors were encountered: