question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to change the `barColorPrimary` style dynamically for `LinearProgress`?

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Question

How am I able to change the bar color of LinearProgress component dynamically? For example, I would like the color code to be a prop of my component, and in my component, I would like to set the color of the linear progress bar to be that color.


class MyComponent extends React.Component {
  render() {
    const { barColor } = this.props; // the color code, e.g, #efefef
    return (
    <LinearProgress 
      variant="determinate" 
      value={progressBar.quantity} 
      classes={{
        barColorPrimary: <how am I able to associate the barColor here?>
      }}
    />
    );
  }
}

Your Environment

Tech Version
Material-UI beta 44
React 16.2.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Jun 20, 2018

The new documentation section is live: https://material-ui.com/customization/overrides/#2-dynamic-variation-for-a-one-time-situation. Right now, people have to either use CSS variables or Theme nesting.

0reactions
fauskangercommented, Jul 9, 2018

I already use withTheme()

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Question] How to change the barColorPrimary style ... - GitHub
How am I able to change the bar color of LinearProgress component dynamically? For example, I would like the color code to be...
Read more >
color change for the loading bar component of material ui
It is because you set the CSS is not correctly, const styles = { root: { flexGrow: ... First set a className to...
Read more >
Change the html progress bar color dynamically bas...
Hi Team, I am using a html text control to make a progress bar and the text is as below.. Everything works fine...
Read more >
LinearProgress API - Material UI - MUI
API reference docs for the React LinearProgress component. Learn about the props, CSS, and other APIs of this exported module.
Read more >
React MUI LinearProgress API - GeeksforGeeks
barColorPrimary (.MuiLinearProgress-barColorPrimary): It is the style applied to the bar elements if color is set to primary and bar2 if a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found