0

Using Angular / Bootstrap, I changed CSS variables at runtime, using this line of code :

document.documentElement.style.setProperty(`--${property.name}`, property.value);

for reference, i used this example to deal with bootstrap SCSS imports : https://blog.wick.technology/runtime-dynamic-bootstrap-theme/

It does work, but some of Bootstrap' styles in bootstrap are broken : enter image description here

I guess that's because the calc function does not support my dynamic vars :

.btn-primary {
    color: hsla(0, 0%, calc(-100 * calc(var(--primary-l) - 58.59375%)), 1);
    background-color: var(--primary);
    border-color: var(--primary);
}

Is there any way that I can fix this behaviour ? Can I overload a new definition of btn-primary ?

1 Answer 1

0

I'm not sure if you already solved your problem or not, but I had the same problem and I feel like I solved it.

I basically decided to create the variables "${variable}-h",${variable}-s", ${variable}-l", which are calculated at runtime when defining the variable, converting the RGB color to the different HSL color components.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.