Skip to main content
Equinusocio
June 22, 2023

Add way to change opacity for color variables alias, fills, strokes, etc

  • June 22, 2023
  • 158 replies
  • 17887 views

When aliasing a color variable to another (img 1), or using it directly on an element (img 2), we should be able to override the opacity without the need to create a variable for each transparency variation:

Cant override opacity in the alias:

CleanShot 2023-06-22 at 10.09.00

Example 2

Cant override the fill opacity:

158 replies

Sourav_Mostafa
October 25, 2023

This will be very helpful. Hope it gets added soon

Till_Hinrichs
New Member
November 10, 2023

+1 Tailwind does this very elegantly:

<p class="text-blue-600/50">The quick brown fox...</p>

You define your fully opaque colours and then make those transparent with the slash. ❤️

midesign
November 14, 2023

Any updates?

elishacoad
November 21, 2023

+1 would be great to ensure better color consistency across variables. Not to mention changing color palettes and building themes would be so much easier this way

digitalBen
New Participant
November 30, 2023

+1 we are missing a way to apply an opacity to an alias variable… when using opacity yuou are required to use hex value instead of alias

Pavel_Kiselev
Power Member
November 30, 2023

I’d use css color-mix(in srgb, var(—brand-100), transparent 50%). Does wonders 😉

Hers is an example Source Foundation / Tailwind CSS

Yuriy_Yarosh
December 1, 2023

The other, a bit more complex, way would be to perform Brightness / Luminance calculations on the shades of gray for contrast variations. The same way Android Dynamic Colors work.

The general idea is to have a conditional for contrast and pick either shades from white to gray, or from shades of black to gray to hit the target Contrast Ratio. Previous Android versions did this by modifying solid white/black opacity, not sure how they’re doing it right now.

So, calculating Color Variables using basic HSL/HSB and Opacity transformations is one thing, but making decisions (conditionals) on Threshold Brightness / Luminance and Threshold Contrast comparison is yet another thing. Having a set of functions to derive and modify colors is just a start.

This is a feature I’m waiting since 2017.

Yuriy_Yarosh
December 1, 2023

Comparisons on color contrasts are crucial for proper Accessibility standards adoption - WCAG contrast ratios are a thing.

Hampus_Svallfors
December 6, 2023

It’s something 😅

twitter.com
Equinusocio
December 7, 2023

…something almost useless compared to what we asked. We didn’t ask for variables for opacities… we asked for aliased variables with opacity. Who the hell is going to create a variable for each opacity?! Opacity is something that doesn’t make sense to standardize because it strongly depends on the context, so where the color is used… this is useful only someone want to create an opacity variable each 10 steps. Like opacity-0, opacity-10, opacity-20 and so one… useless in 99% of the real use cases.