0.1.5 • Published 2 years ago

react-circle-spinner v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-circle-spinner


A customisable circle spinner built with React. Animations are provided by Framer Motion and the circle is created using React minimal pie chart

Live Demo


Installation


Use the following commands to install the package:

npm:

npm install react-circle-spinner

yarn:

yarn add react-circle-spinner

Usage


import CircleSpinner from 'react-circle-spinner';
<CircleSpinner
    segments={[
        { title: 'Yes', value: 50, color: 'green' },
        { title: 'No', value: 50, color: 'red' }
    ]}
    spinOnClick
/>

Props


PropTypeDefaultRequiredDescription
segmentsarray-xArray of segment objects to build up the circle
onResultfunction-Callback function when the spinner lands on an item. The title of the segment will be returned to this function
rotationsBeforeEndnumber2Number of spins before an answer is selected
onSpinStartfunction-Callback function when the spinner starts to spin
spinOnClickbooleanfalseWhen true clicking on the spinner will trigger it to spin
containerStylesobject-Style object to be passed to the container which holds the circle and the needle
circleStylesobject-Style object to be passed to the circle
needleStylesobject-Style object to be passed to the needle
sizenumber200The size in pixels for the spinner
needleWidthnumbersize / 40Width of the needle
needleLengthnumbersize * 0.75Length of the needle
labelStyleobject | function{ fontSize: segment.value / 3 }Style to be provided to the labels. Either a style object or function that returns a style object where the parameter for the function is the segment index

TODO


  • Convert library to use TypeScript

License


MIT