Skip to main content
Equinusocio
Jun 22, 2023 8:10 AM UTC

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

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:

    159 replies

    Sourav_Mostafa
    Oct 25, 2023 11:33 AM UTC

    This will be very helpful. Hope it gets added soon

    Till_Hinrichs
    New Member
    Nov 10, 2023 3:00 PM UTC

    +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
    Nov 14, 2023 1:30 PM UTC

    Any updates?

    elishacoad
    Nov 21, 2023 1:01 AM UTC

    +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
    Nov 30, 2023 6:15 PM UTC

    +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
    Nov 30, 2023 6:35 PM UTC

    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
    Dec 1, 2023 12:32 AM UTC

    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
    Dec 1, 2023 12:42 AM UTC

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

    Hampus_Svallfors
    Dec 6, 2023 6:02 PM UTC

    It’s something 😅

    twitter.com
    Equinusocio
    Dec 7, 2023 9:40 AM UTC

    …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.