Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

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…

Read the release notes

data-strength

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.

Usage

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.

Options

AttributeValuesDefaultEffect
data-strengthboolean, on the input—Adds the meter, level text and rules checklist.
data-rulescomma-separated rules (below)length:8The rules to check. Unknown rules are skipped with a console warning.
data-strength-minfair, good, strongnone (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

RuleMet when the password hasChecklist text
length:Nat least N characters (code points; default 8)"At least N characters"
uppercasean uppercase letter in any script (\p{Lu}: A, É, Ж)"One uppercase letter"
lowercasea lowercase letter in any script (\p{Ll})"One lowercase letter"
numbera digit in any script (\p{N})"One number"
speciala character that is neither a letter nor a digit (space and punctuation count; Cyrillic letters do not)"One special character"

Levels

LevelRules metText colour token
Weakunder 40%--color-error-text
Fair40% to under 75%--color-warning-text
Good75% to under 100%--color-info-text
Strongall--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>:

AttributeDefault
data-label-strength"Password strength" (meter name, announcement prefix)
data-label-strength-weak / -fair / -good / -strong"Weak" / "Fair" / "Good" / "Strong"
data-label-strength-empty"No password entered" (meter value text when empty)
data-label-strength-too-weak"Choose a stronger password. Meet more of the requirements." (validity message with data-strength-min)
data-label-requirements"Password requirements" (checklist name)
data-label-rule-length"At least {n} characters"
data-label-rule-uppercase / -lowercase / -number / -special"One uppercase letter" / "One lowercase letter" / "One number" / "One special character"
data-label-rule-met / data-label-rule-unmet"met" / "not met" (hidden state text after each rule)
data-label-show-password / data-label-hide-password"Show password" / "Hide password" (the toggle)

Events

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.

Styling

No custom properties. The script inserts this after the input (or its show/hide wrapper):

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:

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.

Require a minimum level

Submitting with a weak or fair password shows the validity message.

Localized, with a prefilled value

Fields added later

A <form-field> added after load is enhanced automatically. The input must be inside the field when the field is inserted.

Related

  • <form-field> — required wrapper; also adds the show/hide password toggle.
  • <input type="password"> — the native control, autocomplete, minlength and pattern.
  • <meter> — the element behind the bar, and its low / high / optimum colours.
  • data-accept and data-mask — the other input enhancements for text-like fields.
↑