Skip to main content

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


Show first post

100 replies

Equinusocio

…and that’s what we don’t want.


Equinusocio

Same here… half aliases and half hard values. Not good.


Julian_Behrens

is there a workaround yet? Or a roadmap that tells when variables v2 will be released?


Hampus_Svallfors

Would also love to know if we can expect v2 within the end of the year 🙂


Jakob_Schleenvoigt

Would love this too! In my organisation we would need to reference our Color Primitives and specify the opacity only in the semantic layer. This is currently impossible, I need to create new variables disconnected from the primitive value to achieve this. As it is, this seems to go against the spirit of Variables, would be amazing if this could be added!


Sourav_Mostafa

This will be very helpful. Hope it gets added soon


Till_Hinrichs

+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
  • 2 replies
  • November 14, 2023

Any updates?


elishacoad

+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

+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
  • 438 replies
  • 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

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

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


Hampus_Svallfors

It’s something 😅

twitter.com

Equinusocio
  • Author
  • 39 replies
  • 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.


Equinusocio
  • Author
  • 39 replies
  • December 7, 2023

You can simplify the code by using transparent as starting color so you don’t have to do the calculation:

/* Return a 70% transparent red */
color: color-mix(in oklab, transparent, red 70%)

Equinusocio
  • Author
  • 39 replies
  • December 7, 2023

Also this is basically useless since we can’t set opacity for the shadow color once you set the variable…🤦
CleanShot 2023-12-07 at 11.00.17


Hampus_Svallfors

Agreeing with @Equinusocio, this does not work for me.


Zlatko
  • Active Member
  • 38 replies
  • December 14, 2023

Curious how in the video these variables are accessed. I‘m clicking where the person in the video clicks, but I don‘t get the option to bind it to a variable.


Martin_Mateos_Sanchez

+1 to this! I’ve been struggling with this a lot. The layer workaround in the Tweet is enough for me for now, but directly applying the opacity to a variable referenced by a token would be much better. Hope to see it soon 🙂


Equinusocio
  • Author
  • 39 replies
  • December 14, 2023

Right click on the field. Really subtle. Sometime there is the icon, sometime you have to right click (on textfields). Really bad UI decisions lately.


Zlatko
  • Active Member
  • 38 replies
  • December 14, 2023

Oh, I see. I hope this is a temporary solution because variables are in beta, and they‘ll make it more intuitive after the official launch.


You can also shift + left click the field to go straight to the variables, this works on other variable fields too such as border radius, height etc. Not intuitive but a handy shortcut


Franni
  • New Participant
  • 18 replies
  • January 25, 2024

Replying because I CANNOT believe this is still not possible… How hard is it to implement this much needed feature?


James_Walsh
  • New Participant
  • 16 replies
  • January 30, 2024

Oversights like this make using variables awkward and lead to bad practice when time is tight.

It’s a similar issue to not being able to just apply “bold” or another formatting override to a text style (especially inside a text block!)

It’s adding blockers to a system that’s meant to make everyone’s job easier.

Having to add a seperate variable for every 10 opacity is working harder, not smarter.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings