Home

Awesome

show-password-toggle

Vanilla JavaScript web component that adds a checkbox to show/hide the value of a password input when wrapped in a simple namespaced custom element.

Features

Usage

Import the custom element and wrap your password inputs.

<script type="module" src="ShowPasswordToggle.js"></script>

<!-- wrap password inputs in custom element -->
<show-password-toggle>
  <input type="password" name="…" id="…">
</show-password-toggle>

<!-- add optional attributes to the custom element -->
<show-password-toggle label="Show/Hide" label-class="inline" min-length="12">
  <input type="password" name="…" id="…" pattern=".{12,}">
</show-password-toggle>

Options

Attribute nameTypeBehavior
labelStringDisplay this instead of 'Show password'
label-classStringApply this/these classes to the label
langStringApply this lang attribute to the label
min-lengthIntIf greater than 0, show a pie chart and a label describing minimum password length
min-length-labelStringDisplay this instead of 'At least ### characters' (### is replaced with the min-length attribute)

Styling

License

GNU LGPL 3.0