Color
Opacity / Alpha
Opacity, also called alpha, is a value for how much an element shows through, used to convey overlap, overlay, or disabled states without changing its color.
Definition
Opacity is a value that describes how much an element shows through. When something is fully opaque, whatever sits behind it is completely hidden. When it's fully transparent, the element seems to vanish and the background shows straight through. In between those two extremes, the element becomes semi-transparent, and its color blends with the background layered underneath. This is often called alpha. By adjusting it, you can show states like overlap, overlay, or disabled without deleting or redrawing anything. What sets opacity apart from other color properties is that you aren't changing the color itself — you're changing how much the element is present.
Why does it matter?
Opacity matters because it's the simplest way to express layers between elements. When you open a modal and cover the page behind it with a semi-transparent black sheet, users instantly understand that the screen they were looking at has stepped back and their attention belongs on the window in front. Dim a disabled button and it reads as "you can't press this right now" without a single word of explanation. In this way opacity quietly signals an element's state and priority. It also helps in another common case: lay a translucent sheet over a busy photo and the text on top stays crisp and readable instead of getting lost in the image. But because it's so convenient, it's easy to overuse — so it's worth being clear about why you're making something show through before you reach for it.
Common mistakes
- Giving body text too much transparency. Making black text semi-transparent can look soft and polished, but it also drops the contrast against the background, which makes the text harder to read. On colored backgrounds the contrast collapses far more than you'd expect.
- Lowering the opacity of a whole element when you only meant to fade one part of it. Setting opacity on an element makes everything inside — the text, the shadow, every child element — fade along with it. If you only want the background to be semi-transparent, it's better to put an alpha value into the color itself.
- Making a scrim far too dark. If you dim the background behind a modal too heavily, the context of what you were working on disappears entirely, and users can lose their bearings and feel boxed in. A gentle dim that still lets the background peek through is usually enough to pull focus onto the front window.
Practical tips
- Use opacity for scrims that darken the background behind a modal, or for fading a disabled button. Just don't over-fade text — if you need muted text, it's safer to pick a gray with enough contrast built in from the start rather than making a solid color transparent.
- When you use a semi-transparent color, check the final result on top of the actual background it will sit over. A translucent gray that looked fine on white can turn into a completely different color on a dark background.
- When you split layers with opacity, manage the stacking order alongside it. The translucent effect only stacks the way you intended once it's clear which element sits on top.
Ask your AI
In the modal/overlay code below, fix the scrim that dims the page behind it. Make the backdrop a semi-transparent black around rgba(0,0,0,0.4)–0.5, and don't push the alpha past 0.7 so the context behind still peeks through instead of vanishing completely. Put the dimming on the scrim's background-color alpha rather than the element's opacity, so the modal content on top stays sharp, and sort out the z-index stacking too (scrim below, modal above). Give me the updated CSS and explain why you picked each alpha value.
In the code below, an element's opacity is fading everything inside it — the text, the icons, the box-shadow — along with the background. I only want the background to be semi-transparent, so drop the opacity on the element and instead give background-color an alpha color like rgba() or hsl(... / <alpha>) so the child elements stay fully crisp. Set the alpha to match [the background I want — e.g. a translucent white card at 85%], and explain the before/after difference.
In the code below, find every bit of body or secondary text that's been faded with opacity or semi-transparent black like rgba(0,0,0,0.5). Fading with transparency collapses contrast against the background — especially colored ones — so strip the transparency and swap in a solid gray that has enough contrast built in from the start. Check each one against the actual background color it sits on and make sure it clears 4.5:1 contrast for body text; if it falls short, propose a darker gray. Give me a table mapping the old value to the new color with each contrast ratio.