Circular Slider in React

In this blog we are going to learn how to make Cicrular Slider in react

First you need to install dependencies
npm i @fseehawer/react-circular-slider

Code Use in Tutorial

import React from “react”;

import CircularSlider from “@fseehawer/react-circular-slider”;

import { GoDashboard } from “react-icons/go”;

import “./App.css”;

const CircularSliderExample = () => {

  const [value, setValue] = React.useState(0);

  return (

    <div className=”app”>

      <CircularSlider

        width={200}

        height={200}

        min={0}

        max={20}

        label=”Mechanica Coder”

        dataIndex={value}

        onChange={(value) => setValue(value)}

      >

        <GoDashboard x=”9″ y=”9″ width=”50px” height=”50px” />

      </CircularSlider>

    </div>

  );

};

export default CircularSliderExample;

Props

proptypedefaultAffects
widthnumber280width of the slider
directionnumber1clockwise (1) or anticlockwise (-1)
minnumber0smallest value
maxnumber360largest value
dataarray[]array of data to be spread in 360°
dataIndexnumber0initially place knob at a certain value in the array
knobColorstring#4e63eaknob color
knobSizenumber32knob size
hideKnobbooleanfalsehide knob
knobDraggablebooleantrueknob draggable
knobPositionstringtopknob’s 0 position to be toprightbottom or left
labelstringANGLElabel
labelColorstring#272b77label and value color
labelBottombooleanfalselabel position at bottom
labelFontSizestring1remlabel font-size
valueFontSizestring4remlabel value font-size
appendToValuestringappend character to value
prependToValuestringprepend character to value
renderLabelValuejsxnulladd custom jsx code for the labels and styles
verticalOffsetstring2remvertical offset of the label and value
hideLabelValuebooleanfalsehide label and value
progressColorFromstring#80C3F3progress track gradient start color
progressColorTostring#4990E2progress track gradient end color
progressSizenumber8progress track size
progressLineCapstringroundprogress track cap to be round or flat
trackColorstring#DDDEFBbackground track color
trackSizenumber8background track size
onChangefuncvalue => {}returns label value
isDraggingfuncvalue => {}returns isDragging value

Some Other Example of the code Work
You can find it here

Leave a Reply