1.0.5 • Published 3 years ago

react-toggle-btn v1.0.5

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

Props

The component takes the following props.

PropType
mainColorstring
subColorstring
borderColorstring
FrameWidthstring
FrameHeightstring
CircleWidthstring
CircleHeightstring
CircleTopstring
CircleLeftstring
CircleRightstring
onChangefunction

Installation

npm i react-toggle-btn

Usage

import ToggleButton from "react-toggle-btn";

Sample Code

import { useRef } from "react";
import "./App.css";

import ToggleButton from "react-toggle-btn";

function App() {
  const backgroundRef = useRef(null);

  // This function is a sample for changing color theme.
  const changeColorHandler = (event) => {
    if (event.target.checked) {
      backgroundRef.current.style.backgroundColor = "#000000";
    } else {
      backgroundRef.current.style.backgroundColor = "#ffffff";
    }
  };

  return (
    <div className="App" ref={backgroundRef}>
      <ToggleButton onChange={changeColorHandler} />
    </div>
  );
}

License

MIT

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago