Password Input
Introduction
Section titled “Introduction”A password field built on a native password <input>. It provides:
- label, help text, required indicator, and localized validation (length, pattern, custom);
- a show/hide toggle button (
aria-pressed, constant name “Show password”); autocompletefor password managers:current-password(default) ornew-password;- an optional Caps Lock warning;
- a clipboard policy (paste is allowed by default);
- the
FormControlcontract.
The value never appears in events, messages, or announcements. This is an input, not an authentication provider: AbsoluteUI does not handle credentials, hashing, policy, or sessions.
- Reveal toggleAn accessible show and hide button switches between masked and plain text.
- Caps Lock warningWarns while Caps Lock is on and announces it to screen readers.
- Password managersAutocomplete hints for current and new passwords keep managers working.
- Clipboard policyAllow paste, block copying, or block both, depending on the form.
- Form readyLength, pattern, and custom validation with errors like every field.
Use it for
- Sign-in, sign-up, and change-password forms.
- Any secret the user types and may want to check visually (show/hide).
Use something else for
- One-time codes and PINs: use OTP Input.
- Non-secret text: use Text Input.
- As a replacement for server-side password policy or authentication.
Anatomy
<div class="aui-field aui-password-input [--invalid] [--disabled]"> <label class="aui-field__label" for="I">Password<span aria-hidden="true">*</span></label> <div class="aui-password-input__control"> <input id="I" class="aui-password-input__input" type="password" autocomplete="current-password" spellcheck="false" autocapitalize="none" aria-describedby="D E C M"> <button type="button" class="aui-password-input__reveal" aria-label="Show password" aria-pressed="false" aria-controls="I"> <svg aria-hidden="true"/> </button> </div> <div class="aui-field__description" id="D">help text</div> <div class="aui-password-input__caps" id="C" hidden><svg aria-hidden="true"/><span>Caps Lock is on.</span></div> <div class="aui-field__error" id="E">...</div></div>(M = ids passed in describedBy, e.g. a Password Strength Meter)Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Password Input in the Sign-in and account security showcase
Section titled “Password Input in the Sign-in and account security showcase”The part of the Sign-in and account security showcase that uses Password Input. 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']);Sign-in password
Section titled “Sign-in password”import { PasswordInput } from '@absoluteui/components/password-input';
const host = document.querySelector<HTMLElement>('#password');if (host) PasswordInput.create(host, { label: 'Password', name: 'password', required: true });New password with a strength meter
Section titled “New password with a strength meter”import { PasswordInput } from '@absoluteui/components/password-input';import { PasswordStrengthMeter } from '@absoluteui/components/password-strength-meter';
const inputHost = document.querySelector<HTMLElement>('#new-password');const meterHost = document.querySelector<HTMLElement>('#strength');if (inputHost && meterHost) { const password = PasswordInput.create(inputHost, { label: 'New password', name: 'newPassword', autocomplete: 'new-password', required: true, minLength: 12 }); const meter = PasswordStrengthMeter.create(meterHost, { input: password }); 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 { PasswordInput } from '@absoluteui/components/password-input';import '@absoluteui/components/password-input/style.css';First use
Section titled “First use”import { PasswordInput } from '@absoluteui/components/password-input';import '@absoluteui/components/password-input/style.css';
const host = document.querySelector<HTMLElement>('#new-password');if (host) { PasswordInput.create(host, { label: 'New password', name: 'newPassword', autocomplete: 'new-password', minLength: 12, description: 'Use 12 or more characters.', });}More usage
import { PasswordInput } from '@absoluteui/components/password-input';
const host = document.createElement('div');document.body.append(host);PasswordInput.create(host, { label: 'Password', name: 'password', required: true });Using Angular? See Password Input for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”PasswordInput.create(host: HTMLElement, options: PasswordInputOptions): PasswordInputGlobal configuration key: passwordInput (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Visible label (required accessible name). Required. | |
hideLabel |
boolean |
false |
Visually hide the label. |
value |
string |
"" |
Initial value; reset() restores it. |
name |
string |
Form field name. | |
description |
string |
Help text, referenced by aria-describedby. | |
required |
boolean |
false |
Value is required. |
disabled |
boolean |
false |
Disabled. |
readOnly |
boolean |
false |
Read-only. |
minLength |
number |
Minimum length (code points). | |
maxLength |
number |
Maximum length; validated, not truncated. | |
pattern |
string |
HTML pattern semantics (anchored, v flag). | |
autocomplete |
'current-password' | 'new-password' | 'off' |
"current-password" |
Password-manager hint. Use new-password on sign-up and change-password forms. |
revealable |
boolean |
true |
Show the show/hide toggle. |
clipboard |
'allow' | 'block-copy' | 'block-all' |
"allow" |
Clipboard policy. |
describedBy |
readonly string[] |
Extra element ids for aria-describedby (e.g. a strength meter). | |
validate |
(value: string) => string | null |
Consumer validation; the message must not contain the value. | |
icons |
Partial<{ error: IconRef; reveal: IconRef; conceal: IconRef; capsLock: IconRef }> |
Icon slot overrides. | |
validationTiming |
'blur' | 'input' | 'submit' |
"blur" |
When validation messages first appear; afterwards they update live. Globally configurable. |
capsLockWarning |
boolean |
true |
Show a warning while Caps Lock is on and the field has focus. Globally configurable. |
locale |
string |
"en-US" |
Message locale. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
Host element. |
input |
HTMLInputElement |
The native input. |
value |
string |
Current value. |
validity |
FieldValidity |
Current validity. |
revealed |
boolean |
Password shown as text. |
name |
string | null |
Form field name. |
label |
string |
Accessible label (used by the error summary). |
disabled |
boolean |
Whether the control is disabled. |
dirty |
boolean |
Value differs from the initial value. |
touched |
boolean |
Focus has left the control at least once. |
options |
Readonly<PasswordInputOptions> |
Current options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getFormValue(): string |
The value. |
setValue(value: string): void |
Set the value (no events). |
setRevealed(revealed: boolean): void |
Show or mask the password. |
update(options: Partial<PasswordInputOptions>): void |
Merge and apply options. |
reportValidity(): boolean |
Show messages now (marks the control submitted) and return validity. |
setCustomError(message: string | null): void |
External error (server, cross-field rule); null clears it. |
focus(): void |
Move focus to the primary focusable element. |
reset(): void |
Restore the initial value and clear dirty/touched/submitted state. |
destroy(): void |
Remove rendering, registration, listeners, and the configuration subscription. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-input |
{ validity: FieldValidity } |
Yes | No | User edited the value (the value is not in the detail). |
aui-change |
{ validity: FieldValidity } |
Yes | No | User committed the value (native change). |
aui-caps-lock |
{ on: boolean } |
No | No | The Caps Lock warning appeared or disappeared. |
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-input |
Host (also aui-field). |
aui-password-input--invalid | --disabled |
State modifiers. |
aui-password-input__control |
Control boundary. |
aui-password-input__input |
Native input. |
aui-password-input__reveal |
Show/hide toggle. |
aui-password-input__caps |
Caps Lock warning. |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
error |
alert-circle |
reveal |
eye |
conceal |
eye-off |
capsLock |
alert-triangle |
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 | --aui-color-border-strong | --aui-color-disabled-bg | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-hover | --aui-color-surface | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-color-warning-fg | --aui-control-height-md | --aui-control-padding-x | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-weight-medium | --aui-icon-size-sm | --aui-line-height-normal | --aui-line-height-tight | --aui-radius-md | --aui-space-1
TypeScript definitions
type PasswordAutocomplete = 'current-password' | 'new-password' | 'off';type PasswordClipboardPolicy = 'allow' | 'block-copy' | 'block-all';interface PasswordInputConfig { validationTiming: ValidationTiming; capsLockWarning: boolean }interface PasswordInputOptions extends Partial<PasswordInputConfig> { label: string; hideLabel?: boolean; value?: string; name?: string; description?: string; required?: boolean; disabled?: boolean; readOnly?: boolean; minLength?: number; maxLength?: number; pattern?: string; autocomplete?: PasswordAutocomplete; revealable?: boolean; clipboard?: PasswordClipboardPolicy; describedBy?: readonly string[]; validate?: (value: string) => string | null; locale?: string; icons?: Partial<PasswordInputIcons>;}interface PasswordInputValueDetail { validity: FieldValidity }interface PasswordInputCapsLockDetail { on: boolean }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: Native password <input> with <label for>, plus a toggle button (aria-pressed).
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 |
|---|---|---|
| Tab / Shift+Tab | Any | Moves to the input, then the toggle. |
| Enter / Space | Toggle focused | Shows or hides the password; focus stays on the toggle. |
| All editing keys | Input focused | Native text editing. |
| Element | Role |
|---|---|
| input | none: password inputs have no ARIA role (exposed as a protected text field) |
| toggle | button (native), toggle via aria-pressed |
| icons | none (aria-hidden=true) |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-describedby |
input | Help text, visible error, Caps Lock warning (while shown), then describedBy ids |
aria-invalid |
input | “true” only while an error message is shown |
aria-pressed |
toggle | “true” while the password is shown; the name stays “Show password” |
aria-controls |
toggle | Input id |
The control boundary shows the focus indicator; the toggle has its own :focus-visible outline.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- WCAG 3.3.8 (Accessible Authentication): paste and password managers are allowed by default.
- Visibility changes are announced (Password shown / Password hidden); Caps Lock on is announced once per change.
- The toggle keeps a constant name with aria-pressed; changing the name as well would be read as a contradiction.
- Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/password-input |
43.6 kB | 14.8 kB | 13.2 kB | 0.9 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| PasswordInput.create, per instance (1,000 instances) | < 1 ms average in headless Chromium |
Tested scale: 1,000 inputs on one page in the performance test.
Same structure as Text Input. Budget: PasswordInput.create < 1 ms per instance (1,000 instances, e2e performance suite).
Measured run times: Performance.
Details
Section titled “Details”States
default, focus-visible, filled, revealed, caps lock on, disabled, read-only, required, invalid.
State transitions
| From | Trigger | To |
|---|---|---|
| masked | toggle (click, Enter, Space) or setRevealed(true) |
revealed (type="text", aria-pressed="true", announced “Password shown”) |
| revealed | toggle, setRevealed(false), or reset() |
masked (announced “Password hidden” when toggled) |
| any | key or mouse event with Caps Lock on | warning shown, described, announced once |
| warning | Caps Lock off or blur | warning hidden |
Accessibility notes
- WCAG 3.3.8 Accessible Authentication: paste and password managers work by default; do not block paste.
- Visibility changes and Caps Lock are announced politely.
- Manual screen-reader verification is pending.
Responsive behavior
Full width of its container; the toggle stays a square at the inline end.
Right-to-left
Logical properties: the toggle sits at the inline end in both directions.
Theming
Control surface, border, focus, and error tokens as Text Input; Caps Lock warning in color-warning-fg with an icon. Forced-colors mode: Highlight outline on focus.
Global configuration
configureAbsoluteUI({ components: { passwordInput: { capsLockWarning: false, validationTiming: 'submit' } } });Component configuration
Instance options override global and theme defaults. All options are dynamic.
Icons
icons.reveal (default eye), icons.conceal (eye-off), icons.capsLock (alert-triangle), icons.error (alert-circle).
Security
- The value never appears in events, validation messages, or announcements; the component never logs.
spellcheckis off (spelling services may send text off-device),autocapitalizeisnone.- The clipboard policy is a deterrent, not a security boundary; blocking paste harms security (it discourages password managers).
- Edge’s built-in reveal control is hidden (
::-ms-reveal) to avoid a second toggle. - Revealing is the user’s choice and shows the password on screen.
- AbsoluteUI is not an authentication provider: transport the value over HTTPS, and let the server hash and enforce policy.
Data handling
The value lives only in the native input (for native form submission when name is set) and is returned by getFormValue(). No persistence, logging, network access, or telemetry.
Supported data scale
One value per field; tested with 1,000 fields on a page.
Edge cases
- Caps Lock state is known only after a key or mouse event in the field.
- Revealed passwords are masked again by
reset()and wheneverrevealablebecomesfalse. - Removing the focused toggle (
update({ revealable: false })) is safe (regression covered). maxLengthis validated, not truncated, so long pasted values are reported instead of silently cut.
Errors
| Code | Category | Cause |
|---|---|---|
PASSWORD_INPUT_OPTIONS |
configuration | Missing label, invalid lengths, autocomplete, clipboard policy, or describedBy ids. |
FIELD_PATTERN |
configuration | Invalid pattern. |
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION |
configuration | Invalid or unknown configuration. |
Known limitations
- Caps Lock detection depends on
getModifierState. - Manual screen-reader verification is pending.
Unsupported scenarios
- HTML in the label, help text, or messages.
- Remembering passwords (password managers do this).
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.