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
  • 17886 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

kmh
New Member
July 25, 2023

I was just switching over a Material Design library and hit this roadblock. Material Design 3 has 5 elevation levels of surfaces, which are defined by a fill of 2 colours: the surface colour, and then a semi-transparent tint of the primary colour in a given percentage for each level of elevation. Right now it’s defined as hex values. If I try to say it’s the variables surface at 100% opacity plus primary at, say, 5% opacity, it just changes it to 100% primary with no way to adjust it.

Figma provides the CSS for the current definition using hex for the colour definitions as:

background: var(--m-3-surfaces-light-surface-1, linear-gradient(0deg, rgba(51, 92, 168, 0.05) 0%, rgba(51, 92, 168, 0.05) 100%), #FFFBFE);

The lack of an ability to set a transparency level for a color variable means I can’t use the feature fully. Instead I’ll have solid colours using variables, and any tints/mixes using hex literals.

fork
August 1, 2023

Definitely need this – please Figma devs 🙏

Vincent_Schlothauer
Active Member
August 1, 2023

In addition to what Equinusocio shared, our team uses design tokens to express opacity as well. So to expand on the shared example, we might have something like this:

Lukasz_Grondecki
August 1, 2023

You can add Variable with ALPHA Color. Check this solution

Vincent_Schlothauer
Active Member
August 1, 2023

That’s true, but unfortunately it doesn’t solve the problem. When you define a core palette of colours, each core token/variable will be a solid colour, such as –color-brand-10, –color-brand-20 (…) –color-brand-100. Design tokens reference these core variables in semantic tokens – let’s say your standard background colour for buttons and other interactive elements is –color-background-default, which references –color-brand-40.

If you have components like tooltips that overlay other UI elements, and you want to give them transparency, you’d ideally want to use another semantic token like –color-background-overlay, which references the same –color-brand-40 as your other token, but also adds opacity. This currently isn’t possible. Our team is using a temporary workaround by creating semantic tokens with transparency as hard values rather than as references to core variables. In the Tokens Studio plugin, you were able not only to add hard opacity values to semantic tokens, but also create opacity tokens.

Equinusocio
August 1, 2023

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

Equinusocio
August 1, 2023

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

Julian_Behrens
September 22, 2023

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

Hampus_Svallfors
September 29, 2023

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

Jakob_Schleenvoigt
New Member
October 16, 2023

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!