0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Password strength meter and rules checklist for a password input inside form-field. Advisory by default; data-strength-min makes weak passwords invalid.
Overview
data-strength adds a strength meter and a rules checklist under a password input. Each rule in data-rules counts equally; the share of rules met gives the level: weak, fair, good or strong. The meter is a native <meter>, the level is also written as text, and each rule says whether it is met.
The input must be inside <form-field>; a bare input is not enhanced. The rules are advisory unless you add data-strength-min.
Every input[type="password"] inside <form-field> also gets a show/hide button automatically; there is no attribute to add. The meter and the toggle work together.
The rules to check. Unknown rules are skipped with a console warning.
data-strength-min
fair, good, strong
none (advisory)
A non-empty password below this level is invalid: the input gets a custom validity message and the form will not submit. An empty value is left to required.
Rules
Rule
Met when the password has
Checklist text
length:N
at least N characters (code points; default 8)
"At least N characters"
uppercase
an uppercase letter in any script (\p{Lu}: A, É, Ж)
"One uppercase letter"
lowercase
a lowercase letter in any script (\p{Ll})
"One lowercase letter"
number
a digit in any script (\p{N})
"One number"
special
a character that is neither a letter nor a digit (space and punctuation count; Cyrillic letters do not)
"One special character"
Levels
Level
Rules met
Text colour token
Weak
under 40%
--color-error-text
Fair
40% to under 75%
--color-warning-text
Good
75% to under 100%
--color-info-text
Strong
all
--color-success-text
An empty input has no level. The value is checked when the field is set up (so prefilled or browser-restored values show at once), on every input, and after a form reset.
Text
All strings are data-label-* attributes on the <form-field>:
No custom events. Listen for the native input event and read the generated meter: .strength-meter carries data-level (weak, fair, good, strong or empty) and its <meter> holds the number of rules met.
Reading the level on input
12345678910
const input = document.querySelector('#password');const field = input.closest('form-field');// Listen on the field: the bubbling event reaches it after the meter's own// listener on the input has updated the level.field.addEventListener('input', () => {const wrap = field.querySelector('.strength-meter');const meter = wrap.querySelector('meter');console.log('Level:', wrap.dataset.level, 'Rules met:', meter.value, 'of', meter.max);});
Styling
No custom properties. The script inserts this after the input (or its show/hide wrapper):
Generated structure
12345678910
<divclass="strength-meter"data-level="fair"><meterclass="s"aria-label="Password strength"aria-valuetext="Fair"min="0"max="5"low="2"high="4"optimum="5"value="3"></meter><spanclass="strength-label"aria-hidden="true">Fair</span></div><ulclass="strength-rules"id="strength-1-rules"aria-label="Password requirements"><lidata-rule="length"data-met>At least 8 characters<spanclass="visually-hidden">: met</span></li><lidata-rule="special">One special character<spanclass="visually-hidden">: not met</span></li></ul><spanclass="strength-status visually-hidden"role="status"></span>
The bar is the standard VB <meter> (size s, with a bordered track), so its fill colours come from the meter tokens --meter-fill-even-less-good, --meter-fill-suboptimum and --meter-fill-optimum. The shipped rules for the text:
Shipped strength rules (excerpt)
1234567891011121314
form-field .strength-meter[data-level="weak"].strength-label { color: var(--color-error-text); }form-field .strength-meter[data-level="fair"].strength-label { color: var(--color-warning-text); }form-field .strength-meter[data-level="good"].strength-label { color: var(--color-info-text); }form-field .strength-meter[data-level="strong"].strength-label { color: var(--color-success-text); }form-field .strength-rules {list-style: none;padding: 0;font-size: var(--font-size-s);color: var(--color-text-muted);}/* ::before draws a circle (unmet) or a check (met) */form-field .strength-rulesli[data-met] { color: var(--color-success-text); }
Accessibility
The meter is a native <meter> named "Password strength" whose aria-valuetext is the level name, so it is read as "Fair", not "3".
Level changes are announced through a polite, visually hidden role="status" region, about half a second after typing pauses, so each keystroke does not interrupt.
The rules list is linked to the input with aria-describedby, and every rule ends in hidden "met" / "not met" text, so the state does not rely on the icon or colour.
The level text colours use the status *-text tokens, which keep 4.5:1 against the surface in light and dark mode. In forced-colours mode the rule icons use system colours.
The rules are advice. With data-strength-min, the browser's validation message explains why the form will not submit.
The input needs a visible <label>; use autocomplete="new-password" so password managers can suggest a strong one.
Without JavaScript the input is a normal password field.
Examples
Rule sets
Fewer rules make "strong" easier to reach.
Two rule sets
1234567891011
<form-field><labelfor="str-secure">Password (12+ characters, all rules)</label><inputtype="password"id="str-secure"name="secure"autocomplete="new-password"data-strengthdata-rules="length:12,uppercase,lowercase,number,special"></form-field><form-field><labelfor="str-moderate">Password (6+ characters, uppercase, number)</label><inputtype="password"id="str-moderate"name="moderate"autocomplete="new-password"data-strengthdata-rules="length:6,uppercase,number"></form-field>
Require a minimum level
Submitting with a weak or fair password shows the validity message.
<formlang="fr"><form-fielddata-label-strength="Robustesse du mot de passe"data-label-strength-empty="Aucun mot de passe"data-label-strength-weak="Faible"data-label-strength-fair="Moyen"data-label-strength-good="Bon"data-label-strength-strong="Fort"data-label-requirements="Exigences du mot de passe"data-label-rule-length="Au moins {n} caractères"data-label-rule-uppercase="Une majuscule"data-label-rule-number="Un chiffre"data-label-rule-met="respectée"data-label-rule-unmet="non respectée"data-label-show-password="Afficher le mot de passe"data-label-hide-password="Masquer le mot de passe"><labelfor="str-fr">Mot de passe</label><inputtype="password"id="str-fr"name="mdp"autocomplete="new-password"data-strengthdata-rules="length:8,uppercase,number"value="Été2026"></form-field></form>
Fields added later
A <form-field> added after load is enhanced automatically. The input must be inside the field when the field is inserted.
Adding a strength field from script
1234567
const field = document.createElement('form-field');field.innerHTML = ` <label for="new-pw">Password</label> <input type="password" id="new-pw" name="password" autocomplete="new-password" data-strength data-rules="length:8,uppercase,number">`;document.querySelector('form').append(field);// The meter, checklist and show/hide toggle are added on insertion
Related
<form-field> — required wrapper; also adds the show/hide password toggle.