lovely-toggle-switch
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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.

Package Sidebar

Install

npm i lovely-toggle-switch

Weekly Downloads

6

Version

1.0.5

License

MIT

Unpacked Size

11.9 kB

Total Files

13

Last publish

Collaborators

  • lovenish