React SVG Donuts
A ReactJS component for simple (and complex) SVG donuts.
Dependencies
- NodeJS
- NPM / Yarn
- React and ReactDOM
- A ReactJS application
Usage
First install the package
Then
Props
progress: number (required)
- should be between 0 and 100 and represent the amount of the donut that should be filled. Works with negative values too (between -100 and 0).onRender: function (required)
- any function which returns a valid React node (either React element or null).prefix: string (optional)
- a string which will be used as prefix for all CSS classnames. Defaults todonut
.
CSS
There is a predefined stylesheet which can be used as is.
If you want it, just import it:
Bonus - Complex Donut
Props
size: number (required)
- The size of the donut (width and height).radius: number (required)
- The radius of the donut.segments: array (required)
- An array of donut segments with the following shape:thickness: number (required)
- A number for the thickness of the donutstartAngle: number (required)
- A degree between -360 and 360className: string (optional)
- Well, a custom css class namecircleProps: object(optional)
- Your custom svg circle propstextProps: object(optional)
- Your custom svg text props
CSS
There is a predefined stylesheet which can be used as is.
If you want it, just import it: