caniuse icon indicating copy to clipboard operation
caniuse copied to clipboard

Add CSS Color Module Level 5 (color-mix(), color-contrast(), Relative color)

Open Schweinepriester opened this issue 5 years ago • 9 comments


  • Virtually following up color-mod #2864
  • The color-adjust() function is not to be confused with the property of the same name https://caniuse.com/#search=color-adjust
  • We could consider creating an issue for each of the functions

Schweinepriester avatar May 01 '20 02:05 Schweinepriester

Two are coming as experimental with Safari TP 122:

  • Added experimental support for CSS Color 5 color-contrast() (r273683)
  • Added experimental support for CSS Color 5 color-mix() (r273244)

Schweinepriester avatar Mar 11 '21 22:03 Schweinepriester

color-contrast() as well:

  • https://caniuse.com/mdn-css_types_color_color-contrast
  • https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-contrast()

color-adjust() has been removed, per https://www.w3.org/TR/css-color-5/#changes-20210601:

Removed color-adjust(), keeping relative color syntax


I hadn't listed relative color syntax aka. "CSS Relative Colors", added now. More links:

  • https://www.w3.org/TR/css-color-5/#relative-colors
  • https://blog.jim-nielsen.com/2021/css-relative-colors/
  • https://dev.to/fabiogiolito/create-a-color-theme-with-these-upcoming-css-features-4o83

Schweinepriester avatar Nov 26 '21 10:11 Schweinepriester

Support bugs, stolen from https://www.bram.us/2021/12/27/css-in-2022/#the-hotlist--color-functions:

Schweinepriester avatar Dec 27 '21 23:12 Schweinepriester

With color-adjust() removed from the spec and color-mix() and color-contrast() being covered by MDN data (via mdn/browser-compat-data#9489, mdn/browser-compat-data#12039), that appears to leave this issue only covering relative colors.

The spec also defines @color-profile and device-cmyk(), but both already have an MDN page, so they're likely to be covered by MDN data in the future: https://developer.mozilla.org/en-US/docs/Web/CSS/@color-profile https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/device-cmyk()

GPHemsley avatar Jan 17 '22 01:01 GPHemsley

that appears to leave this issue only covering relative colors.

Check!

The spec also defines @color-profile and device-cmyk(), but both already have an MDN page, so they're likely to be covered by MDN data in the future

Good to know! Those have also separate issues:

  • device-cmyk(): #1314
  • @color-profile: #5958

Schweinepriester avatar Jan 17 '22 01:01 Schweinepriester

Please give us the ability to be able to set the opacity of a custom property that is set to a hex color code. This is propably the most common use case for color adjustments. If you have a theme, each color is one variable (a hex color code), not 3 x RGB values one has to keep track of.

188K designers have sought for a fix for this on stackoverflow: https://stackoverflow.com/questions/40010597/how-do-i-apply-opacity-to-a-css-color-variable

:root {
  --color: #f0f0f0;
}

#element {
  background: (somehow use var(--color) at some opacity);
}

mangelozzi avatar May 27 '22 13:05 mangelozzi

@mangelozzi I think you should voice this pain point at https://github.com/w3c/csswg-drafts/labels/css-color-5 More generally, methodically looking at the most popular CSS stackoverflow questions that have unsatisfying answers, and reporting them on the CSS specs working group would be a way to yield dramatically significant, reality-aligned improvements to CSS.

LifeIsStrange avatar May 27 '22 14:05 LifeIsStrange

Links for relative colors:

  • Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1274133
  • Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1701488
  • Implemented in Webkit behind a flag: https://bugs.webkit.org/show_bug.cgi?id=221880 (Safari TP 122)

Ugoku avatar Oct 12 '22 09:10 Ugoku

Links to issues for color-contrast:

  • Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1111385
  • Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1682439
  • Implemented in Safari already behind a flag

Ugoku avatar Oct 31 '22 08:10 Ugoku

Let's get these pages on Can I Use!

jensimmons avatar Mar 18 '23 01:03 jensimmons

Safari 16.2 added support for color-mix() back in December 2022.

jensimmons avatar Mar 18 '23 01:03 jensimmons

Safari 16.4 beta has support for Relative Color Syntax.

jensimmons avatar Mar 22 '23 21:03 jensimmons

yes, please add relative color syntax to caniuse! i've been checking for it periodically and end up slapping my forehead each time thinking i wasn't putting in the right incantations into the search box, to then finally realize it's not in there at all yet.

clairity avatar Apr 20 '23 23:04 clairity

Safari 16.4 shipped with support for relative color at the end of March

controversial avatar Apr 25 '23 14:04 controversial

Someone needs to make three pull-requests.

What is the current state of all the other browser support? Does Chrome/Edge/other Chromium mobile browsers or Firefox support any of these three new features? Even in partial experimental state?

Can anyone find issues for Chromium and Gecko so we can link to them?

Are there any MDN pages yet?

jensimmons avatar Apr 25 '23 17:04 jensimmons

@jensimmons To my understanding the only thing missing from caniuse covered by this issue is relative color, with the rest being available via MDN:

  • color-mix()
    • https://caniuse.com/mdn-css_types_color_color-mix
    • https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix
  • color-contrast()
    • https://caniuse.com/mdn-css_types_color_color-contrast
    • https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-contrast

Issues for relative color (comment above):

Links for relative colors:

Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1274133 Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1701488 …

Schweinepriester avatar Apr 25 '23 20:04 Schweinepriester

Relative color syntax now available at https://caniuse.com/css-relative-colors

Closing this ticket now as all appear to be accounted for now, thanks all for helping to provide info. :)

Fyrd avatar May 01 '23 20:05 Fyrd