- Plugins
- Strong Password
Plugins
Tailwind CSS Strong Password
Use strong passwords based on required characters.
Installation
To get started, install Strong Password plugin via npm, else you can skip this step if you are already using Preline UI as a package.
npm i @preline/strong-password
Example
Here is an example of a strong password with level of weakness, hints and progress.
Your password must contain:
- Minimum number of characters is 6.
- Should contain lowercase.
- Should contain uppercase.
- Should contain numbers.
- Should contain special characters.
Basic usage
Prefer to create your own style? Here is a completely unstylized example.
<div class="flex-1">
<input type="password" id="hs-strong-password-input" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400"
/>
<div data-hs-strong-password='{
"target": "#hs-strong-password-input",
"stripClasses": "hs-strong-password:opacity-100 hs-strong-password-accepted:bg-green-500 h-2 flex-auto rounded-full bg-blue-500 opacity-50 mx-1"
}' id="strong-password" class="flex mt-2 -mx-1"
></div>
</div>
<div class="mb-3">
<span id="strong-password-weakness"></span>
</div>
Methods
The HSStrongPassword
object is contained within the global window
object
Force dropdown hint position to be recalculated when scrolling (public method).
const strongPassword = new HSStrongPassword(document.querySelector('#strong-password'));
document.addEventListener('scroll', () => {
if (strongPassword) strongPassword.recalculateDirection();
});
Force dropdown hint position to be recalculated when scrolling (mixed).
const strongPassword = HSStrongPassword.getInstance('#strong-password');
document.addEventListener('scroll', () => {
if (strongPassword) strongPassword.recalculateDirection();
});
Events
An example where a function is run every time a value changes.
const el = HSStrongPassword.getInstance('#strong-password');
el.on('change', ({strength, rules}) => {...});
Demo examples
Looking for prebuilt UI components based on the Tailwind CSS? Preline UI packs hundreds of component examples for all your website needs.