You can apply opacity to a CSS variable by combining it with transparent
using color-mix()
. This allows dynamic styling while preserving theme flexibility. For example:
.element {
outline: 3px solid color-mix(in srgb, var(--accent-color) 50%, transparent);
}
This blends the --accent-color
with transparency, effectively reducing its opacity without altering the original variable.
More info here: https://stackoverflow.com/a/71098929