Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use rgba in CSS Variable? [duplicate]

I'm trying to create this variable in SCSS file. But that doesn't work. Where am I doing wrong?

--orange: #fda63c;
--orange-light: rgba(var(--orange), 0.15);

Doesn't works this also:

--orange: #fda63c;
background-color: rgba(var(--orange), 0.15);
like image 760
doğukan Avatar asked Mar 24 '26 08:03

doğukan


1 Answers

You won't be able to pass a function into rgba, but rgba will accept a variable containing the rgb value of a color.

:root {
--orange: 253, 166, 60;
--orange-light: rgba(var(--orange), 0.15);  
}


p {
  color: var(--orange-light);
}
<p>Hello orange world</p>

jsFiddle

like image 82
Andy Hoffman Avatar answered Mar 26 '26 21:03

Andy Hoffman