1.0.5 • Published 4 months ago

lovely-toggle-switch v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

lovely-toggle-switch

A React switch component to toggle status.

Installation

npm install lovely-toggle-switch

Usage

import React from 'react';
import ToggleSwitch from 'lovely-toggle-switch';

function MyComponent() {
  const [isSwitchOn, setSwitchOn] = useState(false);

  return (
    <ToggleSwitch
      id="myToggle-unique-id"
      checked={true} // Set to `false` for an unchecked switch
       onChange={() => {
         // Your custom logic
          setSwitchOn(!isSwitchOn);
      }}
      disabled={false} // Set to `true` to disable the switch
    />
  );
}

Props:

  • id (required): A unique identifier for the toggle switch.
  • checked: A boolean indicating whether the switch is initially checked or not.
  • onChange: A callback function that will be called when the switch state changes.
  • disabled: A boolean indicating whether the switch is disabled or not.

Preview

Preview Image

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Author

Lovenish Goyal

Changelog See the CHANGELOG file for details about changes.

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago