Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the animation speed of a Material-UI Linear Progress Bar indeterminate?

I'm using a LinearProgressBar with the indeterminate variant in a React app to give a feedback that an action is ongoing.

I find that the animation is too fast, is there a way to reduce its speed?

like image 358
Simon Tran Avatar asked Oct 19 '25 19:10

Simon Tran


1 Answers

There is no prop provided in the LinearProgress component to adjust the animation speed so you're going to have to play with class overrides to override the default styles. In this case I'd increase the animation-duration to slow it down:

import { withStyles } from "@material-ui/core/styles";
import LinearProgress from "@material-ui/core/LinearProgress";

const SlowLinearProgress = withStyles({
  bar: {
    // apply a new animation-duration to the `.bar` class
    animationDuration: "8s"
  }
})(LinearProgress);

export default SlowLinearProgress;

Edit slow LinearProgress


For v5 of Material-UI, you can use styled instead of withStyles:

import { styled } from "@material-ui/core/styles";
import LinearProgress from "@material-ui/core/LinearProgress";

const SlowLinearProgress = styled(LinearProgress)({
  "& .MuiLinearProgress-bar": {
    // apply a new animation-duration to the `.bar` class
    animationDuration: "8s"
  }
});

export default SlowLinearProgress;

Edit slow LinearProgress

Related answer: How can I smoothly animate a Material UI LinearProgress over a fixed time period?

like image 86
chazsolo Avatar answered Oct 22 '25 12:10

chazsolo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!