Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color and position of CircularProgress?

I'm trying to use CircularProgress provided by Material.

I created this component in order to change its color:

import React, { Component } from 'react';
import { withStyles } from '@material-ui/core/styles';
import { CircularProgress } from '@material-ui/core';

class ColoredCircularProgress extends Component {
render() {
    const { classes } = this.props;
    return <CircularProgress {...this.props} classes={{colorPrimary: classes.colorPrimary}}/>;
}
}

const styles = props => ({
    colorPrimary: {
        backgroundColor: '#FD8907',
    }
});

export default  withStyles(styles)(ColoredCircularProgress);

However on my site it looks like this:

enter image description here

My questions are :

  1. I want the circle to look orange and instead the circle looks still blue and it adds a square orange box behind.

  2. It also displays at the top left corner of my site. How can I place it right in the center?

like image 467
Flama Avatar asked Jan 13 '20 01:01

Flama


People also ask

How do you change the color of the linear progress indicator in flutter?

Step 1: Locate the CircularProgressIndicator of which you would like to change the color. Step 2: Add the valueColor property. Step 3: Assign the AlwaysStoppedAnimation() . Step 4: Inside the AlwaysStoppedAnimation(), add the color of your choice.

What is CircularProgress in react?

As we know that progress indicators inform users about the status of ongoing processes such as loading an app, uploading data, etc. We can use CircularProgress Component in ReactJS to show this circular loading effect. Material UI for React has this component available for us and it is very easy to integrate.


2 Answers

To change the color you can simple do this:

<CircularProgress style={{'color': 'yellow'}}/>

It works for Material-UI v4.x (I didn't try with minor versions)

like image 70
MatiasG Avatar answered Nov 09 '22 14:11

MatiasG


You can override the style by applying css on .MuiCircularProgress-colorPrimary class.

Try this, hope this will work.

Example

.MuiCircularProgress-colorPrimary {
    color: green !important;
}

.MuiCircularProgress-root { 
    left: 43%; 
    position: absolute; 
    top: 44vh; 
}
like image 44
Sohail Ashraf Avatar answered Nov 09 '22 15:11

Sohail Ashraf