-
Notifications
You must be signed in to change notification settings - Fork 756
Description
https://drafts.csswg.org/css-color-4/#contrast-adjuster
Usecase 1: My website uses background-color: #ddd and color: #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>? )'
- First the provided colors are checked. The first one that has sufficient contrast to the base color is picked. The percentage is ignored.
- If none of the provided colors have sufficient contrast, the one with the highest contrast is picked and adjusted as described in the current draft.
- If no color is provided, the method described in the current draft is used.
See my gist for a working Sass implementation.