Password Strength Meter
Introduction
Section titled “Introduction”Advisory password feedback for sign-up and change-password forms. It provides:
- a password requirements checklist (length, character classes, custom rules) with state in text;
- a strength rating (Weak, Fair, Good, Strong) from a pluggable evaluator, with a four-segment bar;
- debounced, polite announcements of the rating and the number of requirements met;
- attachment to a Password Input (or any
<input>), or evaluation of a bound value.
Advisory only, not a security guarantee. The default evaluator counts rules. It does not detect dictionary words, personal data, keyboard patterns, or breached passwords. Your server must enforce the real password policy. AbsoluteUI is not an authentication or security provider.
- Follows any inputAttach it to a Password Input or a native input and it rates as the user types.
- Requirement checklistShows each rule as met or unmet, with built-in and custom requirements.
- Your own evaluatorReplace the default scoring with your own function.
- Polite announcementsScore changes are announced after a pause, not on every keystroke.
Use it for
- Sign-up and change-password forms, next to a Password Input with autocomplete=new-password.
- Showing a password policy as a live checklist.
Use something else for
- Sign-in forms (do not rate existing passwords).
- As the only enforcement of a password policy.
Anatomy
<div class="aui-password-strength-meter aui-password-strength-meter--score-3"> <div class="aui-password-strength-meter__body" id="M"> (describedById) <div class="aui-password-strength-meter__header"> <span class="__label">Password strength</span> <span class="__rating">Good</span> </div> <div class="aui-password-strength-meter__bar" aria-hidden="true"> <span class="__segment __segment--filled"></span> x4 </div> <ul class="aui-password-strength-meter__requirements" aria-label="Password requirements"> <li class="__requirement __requirement--met" data-requirement="min-length"> <svg aria-hidden="true"/><span>At least 12 characters</span><span class="aui-visually-hidden">, met</span> </li> </ul> </div></div>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Password Strength Meter in the Sign-in and account security showcase
Section titled “Password Strength Meter in the Sign-in and account security showcase”The part of the Sign-in and account security showcase that uses Password Strength Meter. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Authentication showcase: sign-in with a one-time code, a password change with live strength// requirements, and the session timeout warning. A simulated server checks the credentials.import { duration, now } from '@absoluteui/core';import { Button } from '@absoluteui/components/button';import { InlineMessage } from '@absoluteui/components/inline-message';import { OtpInput } from '@absoluteui/components/otp-input';import { PasswordInput } from '@absoluteui/components/password-input';import { PasswordStrengthMeter } from '@absoluteui/components/password-strength-meter';import { SessionWarningDialog } from '@absoluteui/components/session-warning-dialog';import { TextInput } from '@absoluteui/components/text-input';import { createShowcase, hostIn, section, toggle, wait } from './kit.js';
const sc = createShowcase({ title: 'Sign-in and account security', description: 'Sign in with the demo password, enter the code, change the password, and try the session timeout warning.', simulated: true,});
const DEMO_PASSWORD = 'correct horse battery';const DEMO_CODE = '135790';
// Sign-in.const signIn = section(sc, 'Sign in', ['password-input', 'otp-input']);const signInForm = document.createElement('form');signInForm.className = 'sc-form';signInForm.noValidate = true;signIn.append(signInForm);const email = TextInput.create(hostIn(signInForm), { label: 'Email', type: 'email', value: 'ada@example.com', required: true, autocomplete: 'email' });const password = PasswordInput.create(hostIn(signInForm), { label: 'Password', required: true, autocomplete: 'current-password', revealable: true, capsLockWarning: true, description: `Demo password: ${DEMO_PASSWORD}` });const code = OtpInput.create(hostIn(signInForm), { label: 'One-time code', length: 6, type: 'numeric', groupSize: 3, autocomplete: 'one-time-code', description: `Sent to your phone. Demo code: ${DEMO_CODE}` });code.host.hidden = true;const messageHost = hostIn(signInForm);const message = InlineMessage.create(messageHost, { tone: 'info', message: 'Not signed in.', live: 'polite' });const submit = Button.create({ text: 'Continue', variant: 'primary', type: 'submit' }, document);signInForm.append(submit.element);
let step: 'password' | 'code' | 'done' = 'password';signInForm.addEventListener('submit', (e) => { e.preventDefault(); void (async () => { if (step === 'password') { if (!email.reportValidity() || !password.reportValidity()) return; submit.setLoading(true); await wait(500); submit.setLoading(false); if (password.input.value !== DEMO_PASSWORD) { password.setCustomError('The email or password is incorrect.'); password.reportValidity(); sc.log('sign-in rejected'); return; } password.setCustomError(null); step = 'code'; code.host.hidden = false; code.focus(); message.update({ tone: 'info', message: 'Enter the 6-digit code.' }); sc.log('password accepted'); } else if (step === 'code') { await verify(code.getFormValue()); } })();});const verify = async (value: string): Promise<void> => { submit.setLoading(true); await wait(400); submit.setLoading(false); if (value !== DEMO_CODE) { code.setCustomError('That code is not valid. Try again.'); code.reportValidity(); sc.log('code rejected'); return; } code.setCustomError(null); step = 'done'; message.update({ tone: 'success', message: 'Signed in.' }); sc.log('signed in');};code.host.addEventListener('aui-complete', () => { if (step === 'code') void verify(code.getFormValue());});sc.listen(password.host, ['aui-caps-lock'], 'password');sc.listen(code.host, ['aui-complete'], 'code');
// Password change.const change = section(sc, 'Change password', ['password-input', 'password-strength-meter']);const changeForm = hostIn(change);changeForm.className = 'sc-form';const next = PasswordInput.create(hostIn(changeForm), { label: 'New password', autocomplete: 'new-password', revealable: true, minLength: 12 });const meter = PasswordStrengthMeter.create(hostIn(changeForm), { label: 'Password strength', input: next.input, showRequirements: true, requirements: [ { id: 'length', label: 'At least 12 characters', test: (v) => v.length >= 12 }, { id: 'mixed', label: 'Upper and lower case letters', test: (v) => /[a-z]/.test(v) && /[A-Z]/.test(v) }, { id: 'digit', label: 'A digit', test: (v) => /[0-9]/.test(v) }, { id: 'reuse', label: 'Not your current password', test: (v) => v !== '' && v !== DEMO_PASSWORD }, ],});const confirm = PasswordInput.create(hostIn(changeForm), { label: 'Confirm new password', autocomplete: 'new-password', validate: (v) => (v === next.input.value ? null : 'The passwords do not match.') });sc.listen(meter.host, ['aui-change'], 'strength');
// Session timeout.const session = section(sc, 'Session timeout', ['session-warning-dialog']);const sessionIntro = document.createElement('p');sessionIntro.textContent = 'Start a session that ends in 25 seconds: the warning dialog opens 20 seconds before the end and offers to stay signed in or sign out.';session.append(sessionIntro);const sessionRow = hostIn(session);sessionRow.className = 'sc-row';const startButton = Button.create({ text: 'Session ends in 25 s', variant: 'secondary' }, document);sessionRow.append(startButton.element);let dialog: SessionWarningDialog | null = null;const startSession = (seconds: number): void => { dialog?.destroy(); dialog = SessionWarningDialog.create({ expiresAt: { kind: 'Instant', epochMilliseconds: now().epochMilliseconds + seconds * 1000 }, warnBefore: duration(Math.min(seconds, 20) * 1000) }); const d = dialog; for (const type of ['aui-open', 'aui-extend', 'aui-sign-out', 'aui-expire'] as const) { d.element.addEventListener(type, (e) => { sc.log(`session ${type}`, e instanceof CustomEvent ? e.detail : undefined); if (type === 'aui-extend') startSession(seconds); }); }};startButton.element.addEventListener('click', () => { startSession(25); sc.log('session started (warning at 20 s left)');});toggle(sc, 'Mask the code', false, (mask) => { code.update({ mask });}, ['otp-input']);toggle(sc, 'Disabled', false, (disabled) => { for (const c of [email, password, code, next, confirm]) c.update({ disabled }); submit.update({ disabled });}, ['password-input', 'otp-input']);Meter attached to a new-password field
Section titled “Meter attached to a new-password field”import { PasswordInput } from '@absoluteui/components/password-input';import { PasswordStrengthMeter } from '@absoluteui/components/password-strength-meter';
const inputHost = document.querySelector<HTMLElement>('#password');const meterHost = document.querySelector<HTMLElement>('#meter');if (inputHost && meterHost) { const password = PasswordInput.create(inputHost, { label: 'New password', autocomplete: 'new-password' }); const meter = PasswordStrengthMeter.create(meterHost, { input: password }); password.update({ describedBy: [meter.describedById] });}Custom rules and evaluator
Section titled “Custom rules and evaluator”import { PasswordInput } from '@absoluteui/components/password-input';import { PasswordStrengthMeter, passwordRequirements, type PasswordStrengthEvaluator } from '@absoluteui/components/password-strength-meter';
const evaluate: PasswordStrengthEvaluator = (value, requirements) => { const met = requirements.filter((r) => r.met).length; if (value === '') return { score: 0 }; return { score: met === requirements.length ? (value.length >= 20 ? 4 : 3) : 1 };};
const inputHost = document.createElement('div');const meterHost = document.createElement('div');document.body.append(inputHost, meterHost);const password = PasswordInput.create(inputHost, { label: 'New password', autocomplete: 'new-password' });const meter = PasswordStrengthMeter.create(meterHost, { input: password, requirements: [ passwordRequirements.minLength(14), passwordRequirements.symbol(), { id: 'no-company', label: 'Does not contain the company name', test: (v) => !v.toLowerCase().includes('acme') }, ], evaluate,});password.update({ describedBy: [meter.describedById] });Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { PasswordStrengthMeter } from '@absoluteui/components/password-strength-meter';import '@absoluteui/components/password-strength-meter/style.css';First use
Section titled “First use”import { PasswordStrengthMeter, passwordRequirements } from '@absoluteui/components/password-strength-meter';import '@absoluteui/components/password-strength-meter/style.css';
const input = document.querySelector<HTMLInputElement>('#pw');const host = document.querySelector<HTMLElement>('#pw-meter');if (input && host) { PasswordStrengthMeter.create(host, { input, requirements: [passwordRequirements.minLength(15)] });}More usage
import { PasswordInput } from '@absoluteui/components/password-input';import { PasswordStrengthMeter } from '@absoluteui/components/password-strength-meter';
const inputHost = document.createElement('div');const meterHost = document.createElement('div');document.body.append(inputHost, meterHost);const password = PasswordInput.create(inputHost, { label: 'New password', autocomplete: 'new-password' });const meter = PasswordStrengthMeter.create(meterHost, { input: password });password.update({ describedBy: [meter.describedById] });Using Angular? See Password Strength Meter for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”PasswordStrengthMeter.create(host: HTMLElement, options?: PasswordStrengthMeterOptions): PasswordStrengthMeterGlobal configuration key: passwordStrengthMeter (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Visible heading. Default: localized “Password strength”. | |
input |
HTMLInputElement | { readonly input: HTMLInputElement } |
Input to follow (Password Input, Text Input, or the element). | |
value |
string |
Evaluate this value instead of following an input (framework bindings). | |
requirements |
readonly { id: string; label: string | ((locale: string) => string); test: (value: string) => boolean }[] |
Checklist rules. Default: defaultPasswordRequirements(). | |
evaluate |
(value: string, requirements: readonly PasswordRequirementResult[]) => { score: 0 | 1 | 2 | 3 | 4; label?: string } |
Scoring. Default: defaultPasswordEvaluator (advisory). | |
icons |
Partial<{ met: IconRef; unmet: IconRef }> |
Icon slot overrides. | |
showRequirements |
boolean |
true |
Render the requirements checklist. Globally configurable. |
announce |
boolean |
true |
Announce the rating and requirement count politely after typing pauses (1 s). Globally configurable. |
locale |
string |
"en-US" |
Message and number-formatting locale. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
Host element. |
describedById |
string |
Id to add to the input’s aria-describedby (rating and checklist). |
result |
PasswordStrengthResult |
Latest result (score, label, requirements); never the password. |
options |
Readonly<PasswordStrengthMeterOptions> |
Current options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
evaluate(value: string): PasswordStrengthResult |
Evaluate and render (no event, no announcement). |
attach(target: HTMLInputElement | { input: HTMLInputElement }): void |
Follow an input. |
detach(): void |
Stop following the input. |
update(options: Partial<PasswordStrengthMeterOptions>): void |
Merge and apply options. |
destroy(): void |
Detach, cancel the pending announcement, remove rendering. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-change |
{ result: { score: 0 | 1 | 2 | 3 | 4; label: string; requirements: readonly { id: string; label: string; met: boolean }[] } } |
Yes | No | The rating or a requirement changed after user input. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-password-strength-meter |
Host. |
aui-password-strength-meter--score-0 .. --score-4 |
Score modifier. |
aui-password-strength-meter__body |
Describing element (id = describedById). |
aui-password-strength-meter__header | __label | __rating |
Heading and rating text. |
aui-password-strength-meter__bar | __segment |
aria-hidden segmented bar (–filled). |
aui-password-strength-meter__requirements | __requirement |
Checklist (–met; data-requirement holds the id). |
aui-password-strength-meter__icon |
Met / not met icon. |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
met |
check |
unmet |
close |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-color-border-strong | --aui-color-error-fg | --aui-color-success-fg | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-muted | --aui-color-warning-fg | --aui-duration-fast | --aui-easing-standard | --aui-font-family-sans | --aui-font-size-sm | --aui-font-weight-semibold | --aui-icon-size-sm | --aui-line-height-tight | --aui-progress-height | --aui-radius-pill | --aui-space-1 | --aui-space-2
TypeScript definitions
type PasswordStrengthScore = 0 | 1 | 2 | 3 | 4;interface PasswordRequirement { readonly id: string; readonly label: string | ((locale: string) => string); readonly test: (value: string) => boolean }interface PasswordRequirementResult { readonly id: string; readonly label: string; readonly met: boolean }interface PasswordStrength { readonly score: PasswordStrengthScore; readonly label?: string }type PasswordStrengthEvaluator = (value: string, requirements: readonly PasswordRequirementResult[]) => PasswordStrength;interface PasswordStrengthResult { readonly score: PasswordStrengthScore; readonly label: string; readonly requirements: readonly PasswordRequirementResult[] }type PasswordStrengthTarget = HTMLInputElement | { readonly input: HTMLInputElement };interface PasswordStrengthMeterConfig { showRequirements: boolean; announce: boolean }interface PasswordStrengthMeterOptions extends Partial<PasswordStrengthMeterConfig> { label?: string; input?: PasswordStrengthTarget; value?: string; requirements?: readonly PasswordRequirement[]; evaluate?: PasswordStrengthEvaluator; locale?: string; icons?: Partial<PasswordStrengthMeterIcons>;}interface PasswordStrengthMeterChangeDetail { result: PasswordStrengthResult }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: Text rating plus a native list of requirements with state in text; a polite live region for debounced summaries. The segmented bar is aria-hidden (the text carries the meaning).
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| None | Any | Not focusable; it follows the input the user types in. |
| Element | Role |
|---|---|
| requirements | list (native <ul>, aria-label “Password requirements”) |
| bar | none (aria-hidden=true) |
| icons | none (aria-hidden=true) |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-label |
requirements list | Password requirements |
aria-hidden |
segmented bar | “true” |
Not focusable. Reference describedById from the input so the rating and checklist are read with the field.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”| Criterion | Level | Note |
|---|---|---|
| 1.3.1 Info and Relationships | A | |
| 1.4.1 Use of Color | A | |
| 1.4.3 Contrast (Minimum) | AA | |
| 1.4.11 Non-text Contrast | AA | |
| 3.3.2 Labels or Instructions | A | |
| 4.1.3 Status Messages | AA |
Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- Each requirement reads “At least 12 characters, met” / “…, not met” (visually hidden state), never icon or color alone.
- After typing pauses for 1 s, one polite summary is announced when it changed: “Password strength: Good. 4 of 4 requirements met.”
- Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/password-strength-meter |
38.8 kB | 13.3 kB | 11.8 kB | 0.6 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| evaluate() with the default rules | < 1 ms in headless Chromium |
Tested scale: Evaluated on every keystroke; announcements are debounced to one per second of pause.
Evaluation runs the requirement tests and the evaluator synchronously; the checklist is re-rendered per evaluation. Budget: evaluate() with the default rules < 1 ms (e2e performance suite).
Measured run times: Performance.
Details
Section titled “Details”States
Score 0 (empty), 1 Weak, 2 Fair, 3 Good, 4 Strong; each requirement met or not met.
State transitions
| From | Trigger | To |
|---|---|---|
| any | input event on the attached input | re-evaluated; aui-change when the result changed; summary announced after a 1 s pause when it differs from the last one |
| any | evaluate(value) |
re-evaluated silently |
| any | empty value | score 0; no announcement |
Accessibility notes
- Status is never conveyed by color or icon alone.
- One polite summary per pause (“Password strength: Good. 4 of 4 requirements met.”), not per keystroke.
- Manual screen-reader verification is pending.
Responsive behavior
Full width; the segments share the width; checklist items wrap.
Right-to-left
Segments fill from the inline start; icons precede text in the inline direction.
Theming
Weak = color-error-fg, Fair = color-warning-fg, Good/Strong = color-success-fg fills on color-surface-sunken; met requirements use color-success-fg with a check icon. Forced-colors mode: Highlight fills, CanvasText borders.
Global configuration
configureAbsoluteUI({ components: { passwordStrengthMeter: { showRequirements: true, announce: false } } });Component configuration
Instance options override global and theme defaults. All options are dynamic.
Icons
icons.met (default check), icons.unmet (default close).
Security
- Advisory only (see Purpose). For stronger feedback, supply an evaluator backed by a vetted strength estimator, and check breached passwords on your server.
- The password is never stored by the meter, logged, emitted, or announced. Requirement tests and evaluators receive it and must not store it either.
- All text is rendered with
textContent. CSP-safe.
Data handling
With input, the value is read on each input event and discarded after evaluation. With value, it is held in the options object until updated. No persistence, network access, or telemetry.
Supported data scale
Designed for up to about 20 requirements.
Edge cases
Default evaluator (documented, not authoritative):
| Condition | Score |
|---|---|
| Empty | 0 |
A single repeated character (for example aaaaaaaaaaaa) |
1 Weak |
| Fewer than half of the requirements met | 1 Weak |
| Some requirements unmet | 2 Fair |
| All met | 3 Good |
| All met and at least 16 characters | 4 Strong |
- Lengths count Unicode code points.
- With no requirements, the default evaluator rates any non-empty password Good (3) or Strong (4).
- An evaluator returning a score outside 0-4 is a configuration error.
Errors
| Code | Category | Cause |
|---|---|---|
PASSWORD_STRENGTH_METER_OPTIONS |
configuration | Invalid label, input, value, evaluator, requirements (duplicate or empty ids, missing label or test), a score outside 0-4, or minLength(n) outside 1-1024. |
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION |
configuration | Invalid or unknown configuration. |
Known limitations
- Synchronous evaluation only.
- Default rules must be aligned with your server policy through
requirements. - Manual screen-reader verification is pending.
Unsupported scenarios
- Asynchronous evaluators (run breach checks in the application, then call
evaluateor pass a custom evaluator result). - HTML in requirement labels.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.