1.0.5 • Published 9 months ago

js-toggle-password v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

JS Toggle Password

This repo enhances the password input fields on your web page by adding a toggle button to switch between masked and plain text passwords.

Features

  • Easily toggle password visibility with a single click.
  • Customize the appearance and behavior of the toggle button.
  • Support for using custom SVG icons for the toggle button.

Demo

Screenshot from 2023-08-08 21-13-36

Usage

HTML

First, input type password have a parent div element.

<html>
    <head></head>
    <body>
        <form>
            <label>Password</label>
            <div>
                <input type="password" name="password" style="width: 100%" />
            </div>
        </form>

        <script type="module">
          import TogglePassword from "./src/index.js";
    
          const togglePassword = new TogglePassword();
          togglePassword.create();
        </script>
    </body>
</html>

Configuration

You can modify toggle password svg styles, postion and svg icons using below property.

PropertyNameType
styleswidthNumber - css in pixels
heightNumber - css in pixels
colorString - hex color code
positionrightNumber - css in pixels
topNumber - css in percentage
iconsvisibleSvgString - svg code
inVisibleSvgString - svg code
const togglePassword = new TogglePassword({
    styles: {
        width: 24, // default
        height: 24, // default
        color: '#000000', // default
    },
    position: {
        right: 8, // default
        top: 50, // default
    },
    icons: {
        visibleSvg: 'svgcode',
        inVisibleSvg: 'svgcode'
    }
});

togglePassword.create();
1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago