-
Notifications
You must be signed in to change notification settings - Fork 689
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] Custom color palettes #5730
Comments
@color-profile a98-rgb {
src: url("adobe.icc"); /* invalid for predefined color profiles */
green: 96% 2% 2%; /* specify existing CSS color names as descriptors */
--my-green: 98% 1% 1%; /* custom color name */
}
foo {
color: color(a98-rgb green);
background: color(a98-rgb --my-green);
} It really doesn't look cleaner. It redefines an existing predefined space, linking to a color profile that is unavailable due to trademark and redistribution-licensing constraints, just to avoid using the already-existing I don't like that syntax at all.
:root {
color-profile: a98-rgb; /* overrides `srgb` default */
}
foo {
color: color(green); /* or just `green`? */
background: color(--my-green); /* different from `var(--my-green)` */
} Overriding all existing colors that have been there since CSS1, with new meanings. A wonderful boon to readability. If you want to propose a way to define a palette of named colors (and then use those names), please propose a different at-rule like Also, as CSS Color 4 is undergoing stabilization prior to going to CR, please propose it for a later spec such as CSS Color 5 or a new css-color-palettes spec. |
For a single color, taking part of your proposed syntax and expressing it with what we already have, --my-green: color(a98-rgb 98% 1% 1%); /* custom color name */ Your proposal should probably explain why the existing CSS Custom Properties are not sufficient. |
With Custom Properties and the Rethinking it, this issue is really about introducing universal (custom) color keywords that can be specified individually for different color spaces and profiles. They would then not be automatically converted from their original space to the one used, but use the manual definition if available. Corporate Design Manuals frequently specify a color palette and provide equivalents for its colors in various media scenarios, e.g. screen, offset printing, wall paint and so on. The name the color is referred by stays the same, regardless of perceived or measured differences in the colors used. For instance, W3C Blue is (or at l least was in 2004) equivalently:
brandpad.io and other sites will record equivalences like this:
|
The
@color-profile
at-rule currently has two possible descriptors,src
andrendering-intent
. It also has a name that is eitherdevice-cmyk
or a custom<dashed-ident>
. This name will be used to specify custom color profiles inside thecolor()
function.The
color()
function supports named colors from profiles, although this is a feature not often used in ISO 15076-1 / ICC color profile files. #817 It is unlikely that browsers will (initially) support fetching and using random ICC profiles from remote sources.Update: If #6095 is accepted, support for color names from profiles will be removed.
I wish one could specify color palettes with named colors within CSS, e.g. for spot colors. Those would be tied to a particular color profile (and space). Therefore, custom properties would not be the proper solution, although they work:
This looks cleaner:
If the default color profile could be set by an inherited property, this would look even cleaner:
Current color names are specified in the default color profile and space, i.e. sRGB. They could be overwritten, but then perhaps only be used within the
color()
function:Instead of adding descriptors to the
@color-profile
at-rule, there could also be a dedicated@color-palette
at-rule.or with a dedicated
palette
descriptor:Except, since this at-rule would need to be independent of the color profile, it should define its colors absolutely:
Alternatively, a new
@color
or@color-name
at-rule could be introduced to define a named color depending on the active color profile:The text was updated successfully, but these errors were encountered: