Skip to content
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

Relative Color Syntax #426

Closed
2 of 3 tasks
Jothsa opened this issue Sep 15, 2023 · 7 comments
Closed
2 of 3 tasks

Relative Color Syntax #426

Jothsa opened this issue Sep 15, 2023 · 7 comments
Labels
focus-area-proposal Focus Area Proposal

Comments

@Jothsa
Copy link

Jothsa commented Sep 15, 2023

Description

CSS Relative colors syntax allows colors to be created from an origin color. The new color can use the color channels of the origin color as is, manipulate them with math functions, or replace them with another value. The CSS Relative color syntax lets developers easily create variants of colors

Specification

https://www.w3.org/TR/css-color-5/#relative-colors

Open Issues

No response

Tests

https://wpt.fyi/results/css/css-color?label=master&label=experimental&aligned&q=relative
https://wpt.fyi/results/css/css-color/parsing?label=master&label=experimental&aligned&q=relative

Current Implementations

  • Blink
  • Gecko
  • WebKit

Standards Positions

No response

Browser bug reports

https://bugs.chromium.org/p/chromium/issues/detail?id=1475009&q=Relative%20Color%20syntax&can=2

https://bugzilla.mozilla.org/show_bug.cgi?id=1701488

Developer discussions

https://stackoverflow.com/questions/55329996/how-to-create-color-shades-using-css-variables-similar-to-darken-of-sass
https://stackoverflow.com/a/71098929
https://chriscoyier.net/2023/01/26/relative-color-syntax-plzzzzz/
https://stackoverflow.com/questions/52037809/add-alpha-channel-to-hex-color-declared-on-css-variable

Polls & Surveys

In the State of CSS 2023 survey, over 1000 developers added relative colors to their reading list. https://2023.stateofcss.com/en-US/features/#reading_list

Existing Usage

No response

Workarounds

https://preset-env.cssdb.org/blog/postcss-relative-color-syntax/

Accessibility Impact

This would make designing accessible color palettes much easier, especially when used with a perceptually linear color space such as oklch. It becomes much easier to create higher contrast variants of colors.

For example:

button {
    background-color: var(—secondary);

    &:hover, &:focus-visible {
        background-color: oklch(from var(—secondary), calc( l + .3) c h);
}

In this example, a hover variant is created of a color, ensuring that the new color is 30% lighter than the old color.

Privacy Impact

No response

Other

No response

@Jothsa Jothsa added the focus-area-proposal Focus Area Proposal label Sep 15, 2023
@lukewarlow
Copy link
Member

lukewarlow commented Sep 15, 2023

Chrome Intent to Ship: https://chromestatus.com/feature/5205844613922816
Looks like it'll be shipped in 119.

Firefox Standards Position: mozilla/standards-positions#841

@svgeesus
Copy link

svgeesus commented Oct 4, 2023

current WPT results for RCS

image

@dholbert dholbert mentioned this issue Oct 16, 2023
3 tasks
@emilio
Copy link

emilio commented Oct 16, 2023

@tiaanl mentioned that WPTs expect gamut mapping at computed value time, is that right @svgeesus? I thought gamut mapping should only happen at used value time?

@emilio
Copy link

emilio commented Oct 16, 2023

Untangling RCS from gamut mapping would be nice in terms of supporting this proposal fwiw.

@tiaanl
Copy link

tiaanl commented Oct 16, 2023

@emilio it was my mistake. Exactly the opposite is true. They should NOT be gamut mapped. Sorry for the confusion. Looking at the gamut mapping interop proposal the tests for gamut mapping refers to the RCS test for not gamut mapping.

@svgeesus
Copy link

@tiaanl mentioned that WPTs expect gamut mapping at computed value time, is that right @svgeesus?

No

I thought gamut mapping should only happen at used value time?

Correct.

@wpt-interop
Copy link

This proposal has been accepted as part of Interop 2024! On behalf of the entire Interop team, thank you for proposing it. You’ll be able to track progress on this topic throughout the year via the Interop 2024 dashboard.

@zcorpan
Copy link
Member

zcorpan commented Feb 1, 2024

Thank you for proposing Relative Color Syntax for inclusion in Interop 2024.

We are pleased to let you know that this proposal was accepted as part of the Relative Color Syntax focus area. You can follow the progress of this focus area on the Interop 2024 dashboard.

For an overview of our process, see the proposal selection. Thank you for contributing to Interop 2024!

Posted on behalf of the Interop team.

@zcorpan zcorpan closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus-area-proposal Focus Area Proposal
Projects
Status: Done
Development

No branches or pull requests

7 participants