Skip to content
Knsept
Free playbook

Password strength meter

A live strength bar with a checklist of rules, plus a show/hide toggle. No library, no dark patterns.

JavaScriptUI Widgets Updated Oct 23, 2026
Live demo Reduced motion is on, so effects are toned down
<form class="pw" novalidate>
  <label for="new-password" class="pw-label">New password</label>
  <div class="pw-field">
    <input id="new-password" type="password" autocomplete="new-password" aria-describedby="pw-rules pw-summary">
    <button class="pw-toggle" type="button" aria-pressed="false">Show</button>
  </div>
  <div class="pw-meter" aria-hidden="true"><span></span></div>
  <p id="pw-summary" class="pw-summary" aria-live="polite">Strength: none</p>
  <ul id="pw-rules" class="pw-rules">
    <li data-rule="length">At least 12 characters</li>
    <li data-rule="mixedCase">Upper and lower case letters</li>
    <li data-rule="number">A number</li>
    <li data-rule="symbol">A symbol, like ! or #</li>
  </ul>
</form>

A checklist beats a bare red/green bar, because it tells people exactly what to change. The bar width is --strength × 25%, and the color comes from the same level table that names it, so the label, color and width can never disagree.

The summary line is aria-live="polite", so screen readers hear "Strength: good" as it changes, and the rules are linked to the input with aria-describedby. The show/hide toggle reports its state with aria-pressed.

A note on real security: these rules are a usability aid, not a guarantee. For production, also check length on the server, and consider rejecting known-breached passwords (for example with the Have I Been Pwned range API) rather than adding more character rules.

More from the library

Forms & inputs live

One-time code input

Six boxes for a verification code. Auto-advance, backspace, arrow keys, paste, and SMS autofill all work.

Forms & inputs live

Range slider with value bubble

A styled native range input with a filled track and a bubble that follows the thumb. Same look in every browser.

Forms & inputs live

Toggle switch

An accessible on/off switch built on a real checkbox with role="switch". Keyboard, touch and screen readers work out of the box.