How to alias RGB with custom Alpha?
See original GitHub issueStyle Dictionary v2.10.2
I would like to do the following:
{
"color": {
"font": {
"primary": { "value": "{color.base.grey.90.value}" },
"secondary": {
"value": {
"r": "{color.base.grey.90.value.r}",
"g": "{color.base.grey.90.value.g}",
"b": "{color.base.grey.90.value.b}",
"a": 0.2
}
}
}
}
}
But I get the following --color-font-secondary: rgba(NaN, NaN, NaN, 0.2);
. Am I missing something? Is there a better way to reference a color, but change the opacity?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
rgba() and hsla() are legacy functions and aliases in modern ...
The specification introduced two changes: rgb() / hsl() accept alpha values. Color functions accept space-separared values. With rgb() ...
Read more >rgb() - CSS: Cascading Style Sheets - MDN Web Docs
The rgb() functional notation expresses a color according to its red, green, and blue components. An optional alpha component represents the color's ...
Read more >Anti-aliased Alpha Test: The Esoteric Alpha To Coverage
You don't need to live with the aliasing of alpha test, the sorting issues of alpha blend, or the cost of a two...
Read more >What is the difference between rgb() and rgba() opacity?
rgb () and rgba(), and hsl() and hsla() are now aliases of each other (all of them have an optional alpha). And. Also...
Read more >Convert anti-aliasing on color to anti-alias on transparent
Open your Channels palette and ctrl+click on the RGB channel to load it's selection, then ctrl+shift+i to inverse the selection. Press the " ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@MrX8503 note with the workaround you described you now have 2 attributes for each colour token:
value
andrgb
, which can get a bit tricky when you need to update it (ensuring both attributes resolve to the same colour).I had the same workaround and found it inconvenient when I had to update colour tokens, so I did this instead:
In the next version of Style Dictionary, 3.0, we are adding the ability to have transitive transforms. This would get around the issue with transforms that @Haemp mentions. Here is an example that shows how to add transparency to colors two different ways. By splitting up the RGB or HSL channels and combining them into a single value, or by defining a custom transitive transform that modifies a color (adding transparency or brightening, darkening, etc.).
To try a pre-release of 3.0 you can install it with: