-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to change the barColorPrimary
style dynamically for LinearProgress
?
#11307
Comments
@franklixuefei It's the second time I see this feedback, let's do something about it. Some options:
|
@oliviertassinari from the options you listed out, I believe the 1st or the 2nd is better. If you think about
However, in doing so, we'd better support BTW, I'm using {this.state.progressBarsInfo.map((progressBar) => {
const barColorStyle = jss.createStyleSheet({
bar: {
['background-color']: progressBar.color
}
}).attach();
return (
<LinearProgress
variant="determinate"
value={total ? progressBar.quantity / total * 100 : 0}
classes={{
root: classnames(classes.bar, classes.transparentBackground),
barColorPrimary: barColorStyle.classes.bar
}}
key={progressBar.name}
/>
);
})} |
@franklixuefei Yeah, I think that option 3 is overkill. I'm happy with 1. or 2. |
@oliviertassinari can i work on this? |
I have made a PR. Now this is how you can change the primary color on Linear Progress
Kindly review the PR #11782 |
before #7633 is supported, there is still no easy way to resolve this issue. |
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 |
I tried to use the example with theme nesting, but the example seems to crash in https://codesandbox.io/s/8n5vl4xxyl - and in my project I get a warning:
|
I already use |
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.
Your Environment
The text was updated successfully, but these errors were encountered: