[CircularProgress] Allow set a gradient stroke
See original GitHub issueHi, I want to set a gradient stroke for the CircularProgress component.
currently using the circle prop exposed by that component: Circular Progress API
const styles = theme => ({
circle: {
stroke: linear-gradient(90deg, #2bb0af 0, #23a7d7)
}
});
but sadly the stroke property does not allow to set the gradient that way. You have to define this way:
<svg width="80px" height="30px" viewBox="0 0 80 30"
xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="Gradient01">
<stop offset="20%" stop-color="#39F" />
<stop offset="90%" stop-color="#F3F" />
</linearGradient>
</defs>
<rect x="10" y="10" width="60" height="10"
stroke="url(#Gradient01)" />
</svg>
I looked through the issues to see if someone else had the same problem and coudln’t find any anwser. The closest thing I got was this comment: https://github.com/mui-org/material-ui/issues/7221#issuecomment-311743969 which is exactly what i want.
Is there a special way to handle this?
Tech | Version |
---|---|
Material-UI | Next |
React | 16.0.0 |
Chrome | 57 |
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
[CircularProgress] Allow set a gradient stroke #9496 - GitHub
Hi, I want to set a gradient stroke for the CircularProgress component. currently using the circle prop exposed by that component: Circular ......
Read more >Circular progress indicator with a color gradient with SVGs?
I'm using the fill-opacity attribute to set the element either fully ... Removing this allows the gradient to apply to the circle's stroke, ......
Read more >Solved: Re: Gradient Circular Progress Bar - Adobe Support ...
I want to make an animated circular progress bar with a gradient in adobe XD (in order to animate the progress bar it...
Read more >How To Make Circular Progress Bar | HTML CSS JavaScript
Make a Circular Progress Bar | HTML CSS JavaScript, step-by-step from scratch. Support our c...
Read more >Circular Progress bar view in SwiftUI - DevTechie
We will also set stroke with AngularGradient, and set stroke style with lineWidth, lineCap and lineJoin. import SwiftUIstruct CustomProgressView ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For those, who seek a convenient way to do this, I want to offer a solution below.
We need to use CircularProgress with SVG linear-gradient and set an id property to that linear-gradient. After, we can define a class that will refer to that id by CSS
url()
function. We add this referred linear-gradient to the “stroke” property of that class.And in the end, we need to add that class to CircularProgress “class” property and override the “circle” class.
Here is the link below to the codesandbox with an example and a gif.
GradientCircularProgress
Mui 5 way: