Replies: 1 comment 2 replies
-
I see what you mean, but unfortunately this isn’t currently possible. The reason is that w3c aliases aren’t allowed just anywhere (they can’t be in the middle of another value); they have to be either the entire Similarly, there may be a way to hack the CSS The spec authors have been playing around with an expanded color type that would allow aliasing individual channels, like so: {
"primaryHue": {
"$type": "number",
"$value":
},
"primary": {
"10": {
"$type": "color",
"$value": {
"colorSpace": "oklch",
"channels": [0.6, 0.216564, "{color.primaryHue}"],
"alpha": 1
}
}
}
} but sadly there’s nothing close to consensus on this yet so there’s a high likelihood this syntax as-written never ships (so I wouldn’t want to make Cobalt depend on it) The only workaround today is to just copy + paste everything manually. Which at first sounds like it’s antithetical to what you want to do. But when you realize many palettes hue shift as they move up/down the scale it might not be such a bad thing. In another sense, locking one axes of your palettes may not be as flexible as you might think! But again, I do think that it’s likely the spec will allow for more color operations soon as it’s the most-requested feature. So there will be a way to do what you originally asked for, but it’s unclear what that would look like today. A proposal may just have to reach more consensus before I’d want to support it in Cobalt (which, by the way, proposals can come from anyone—maybe one you propose will be the right syntax!). |
Beta Was this translation helpful? Give feedback.
-
CSS Variables are declarative which allows the client-side JS to do quite a lot with just a few (or one CSS variable).
I am generating ramps/palettes for an application using a single hue value and OKLCH, which I then allow the user to change and save for their personal accounts. Which would mean I have ramps defined like
I'd like to emulate this using Cobalt where {ref.value} implicitly creates a CSS variable. This also helps greatly for when you have variable type scales, widths, rounding, et cetera that you want to change on the client (my best wishes for the people who built CSS variables).
I also tried an alternate approach where I could possibly say
which returns a
Error: invalid color "oklch(60% 0.216564 var(--primary-hue))"
Beta Was this translation helpful? Give feedback.
All reactions