I have a variable called --primary-color defined at root like this:
:root {
--primary-color: red;
}
In a small section in my site I want to change the primary-color for all nested elements. I currently change the primary color like this:
<button class="PrimaryButton">red</button>
<div style="--primary-color: purple">
<button class="PrimaryButton">purple</button>
</div>
However notice i had to put the purple style on a div. This changes layout. Is there some element or someway I can change the variable without using a layout element like a div? I can't use as that affects global.
Here is example:
:root {
--primary-color: red;
}
.PrimaryButton {
background-color: var(--primary-color);
width: 100px;
height: 40px;
}
<button class="PrimaryButton">red</button>
<div style="--primary-color: purple">
<button class="PrimaryButton">purple</button>
</div>
Thank you!
--primary-color. I would have to make a new button respecting new variable.