Password strength meter in WordPress
A password field that ticks its rules live, measures strength and can be shown or hidden with an accessible button.
Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.
This component also comes in
The code in WordPress
<?php
/**
* Plugin Name: Forge, Mot de passe avec jauge de robustesse
* Description: Un champ mot de passe qui coche ses règles en direct, mesure la robustesse et s’affiche ou se masque d’un bouton accessible. Ajoute la composition « Mot de passe avec jauge de robustesse » à l'éditeur de blocs.
* Version: 1.0.0
* Requires at least: 6.6
* Requires PHP: 8.1
* Author: Forge
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: forge-mot-de-passe-robustesse
*<!-- wp:html -->
<form class="mpr" data-mpr novalidate aria-labelledby="mpr-titre">
<h2 class="mpr-title" id="mpr-titre">Créer votre espace client</h2>
<div class="mpr-field">
<label class="mpr-label" for="mpr-email">Adresse e-mail</label>
<input class="mpr-input" id="mpr-email" name="email" type="email" autocomplete="email" required>
</div>
<div class="mpr-field">
<label class="mpr-label" for="mpr-pass">Mot de passe</label>
<div class="mpr-wrap">
<input class="mpr-input mpr-input--pass" id="mpr-pass" name="password" type="password" autocomplete="new-password" required aria-describedby="mpr-regles mpr-erreur">
<button class="mpr-toggle" type="button" aria-pressed="false" aria-controls="mpr-pass" data-mpr-toggle hidden>(() => {
if (!document.querySelector(".mpr")) return;
document.querySelectorAll("[data-mpr]").forEach((root) => {
const on = (el, type, fn) => el.addEventListener(type, fn);
const form = root;
const pass = form.querySelector("#mpr-pass");
const toggle = form.querySelector("[data-mpr-toggle]");
const error = form.querySelector("[data-mpr-error]");
const done = form.querySelector("[data-mpr-done]");
const LEVELS = ["à saisir", "faible", "moyenne", "bonne", "excellente"];
const TESTS = {
length: (v) => v.length >= 12,:root {
--mpr-card: #ffffff;
--mpr-text: #172033;
--mpr-muted: #4b5568;
--mpr-line: #c5ccd8;
--mpr-field: #ffffff;
--mpr-track: #e5e9f0;
--mpr-accent: #1d4ed8;
--mpr-accent-text: #ffffff;
--mpr-weak: #b91c1c;
--mpr-mid: #b45309;
--mpr-good: #15803d;Free component: copy it freely, including for commercial projects.
Other forms and inputs components in WordPress
Forms and inputs components in WordPress
A quote request form for tradespeople: the customer describes the work, picks a start date range and attaches up to six site photos, each with a preview, its size and a button to remove it.
- Tailwind
- React
- CSS
- WordPress

A quote request form whose labels, hints and error messages are full French sentences, still readable at 320 px: nothing overflows, nothing is cut off, and each error is tied to its field.
- Tailwind
- React
- CSS
- WordPress

Visitors pick a package and tick options: the pre-tax total, VAT and total including tax update live, and the summary is sent with the contact form.
- Tailwind
- React
- CSS
- WordPress

A short NPS survey: a 0 to 10 score as radio buttons, then a follow-up question adapted to whether the customer is a detractor, passive or promoter.
- Tailwind
- React
- CSS
- WordPress

An honest unsubscribe page: address prefilled from the link, choice between stopping everything or receiving less, optional reason and an undo.
- Tailwind
- React
- CSS
- WordPress

A callback request form: French phone number checked and formatted, topic, working day and time slot, with explicit consent to the call.
- Tailwind
- React
- CSS
- WordPress