
The CSS alpha() function takes a relative color and adds transparency to it.
Pretty straightforward, right? Well, there’s more to it. For one, did you see that we’re working with a named color in that last example? Nice, right? Normally we would have to use a hex value or some color function instead to get that same level of transparency because named colors can’t accept alpha values.
Another thing, notice that we’re also working with the relative color syntax in that example. That’s a nice way to make the concept of transforming colors consistent across the board.
When would you need this? It’s a fair question! Sure, it makes sense when working with named colors, but we’re not really supposed to use named colors, right? They don’t always look the same in every browser.
A better use case is when you have a design token for a color that’s a solid value, no matter the type of color value.
And maybe you want to use that color to make chilled out link underlines. You could create a completely new design token just for that instance:
…or you could color-mix() it with transparent:
…or just use the same token and transform it on that instance with some brevity:
Come to think of it, that’s pretty handy for background-color too where you need a lighter variation of a color. I can also see it being used for color theming light and dark modes:
Let’s say you have a design token that already has a bit of alpha transparency on it:
The alpha() function can override that when you might want additional transparency without changing the token at all:
We can also use alpha() with the calc() function. It’s a lot like the last example but we’re calculating the origin color’s alpha rather than setting it explicitly. That’s nice for situations where you want your chill variation to be relative to the origin color’s alpha rather than fixing it to a specific value:
The official alpha() function syntax looks like this:
…where
The alpha() function is defined in CSS Color Module Level 5 which is in Editor’s Draft at the time of writing. That means the information can change between now and when it formally becomes a Candidate Recommendation.
The CSS alpha() function reached “Newly Available” status in September 2026 and is expected to be “Widely Available” in March 2029 at the time of writing.
Join our community of front-end nerds! You'll get into the Discord server and member-only perks and free swag.
Sign up to get front-end roundups, browser updates, and exclusive content sent to your inbox bi-weekly.
Get your t-shirts, prints, stickers, and yes, even mousepads at the brand-spankin' new CSS-Tricks store, now open.
CSS-Tricks is powered by a small team of real-life humans.
Handwritten. Twice a month. No spam. See past issues →