0

Having trouble parameterizing css such that animationSpeed is taken from props.

I would want to replace the .2s below with animationSpeed

transitions.css

.Anim-appear {
  animation: .2s linear pageFadeIn, .2s linear pageSlideInLeft;
}
...

component.jsx

import '../css/transitions.css';

const PageAnimator = props => {
     const animationSpeed = props.animationSpeed + 's' // How to use this to set animationSpeed in CSS?
 }

I am having a lot of trouble doing this and was wondering how I could get this done.

Note: this value doesn't change. After we initialize the app it is a constant value. But we have several versions of the App that all have different configurations and animation speeds.

1 Answer 1

0
  document.documentElement.style.setProperty('--animation-speed', sec);

That's how I accomplished it. It seems to work. : )

Thanks to:

How to change CSS root variable in React?

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.