Password Input
A password field with a show/hide button and an optional strength meter, styled and form-wired like Input.
<arc-password-input>Overview
PasswordInput wraps a native <input type="password"> with the same label, placeholder, validation and sizes as Input. An eye button switches the field between masked and plain text, and show-strength adds a strength meter.
A revealed password stays revealed until the button is pressed again. Blur doesn't re-mask it. The button is a real <button> with aria-pressed and an accessible name.
The meter is a four-segment bar under the field with a label from "Weak" to "Strong". The score rewards length and a mix of character classes, and penalizes repeated characters, runs like "abcd" or "1234", and a built-in list of 20 common passwords. It runs in the browser with no network calls. The meter has role="meter" and announces changes politely.
PasswordInput joins native forms through ElementInternals, like Input: it submits its value under name, supports required, and resets with form.reset(). Use autocomplete="new-password" on sign-up and change-password forms so password managers offer to generate one.
Guidelines
Do
- Give it a `label`. Placeholder text alone isn't one
- Turn on `show-strength` where people create a password, and leave it off on login forms
- Listen to `arc-strength-change` if you block submission below a minimum score
- Pair it with Form for coordinated validation and an error summary
- Use the `error` prop for server or policy failures, for example "Password was found in a breach"
Don't
- Don't treat the score as a security check. Enforce your real policy on the server
- Don't re-mask the field while someone is typing. The toggle state is theirs
- Don't block paste. People paste from password managers
Features
- `arc-strength-change` fires with the 0-4 score, for your own policy UI
- `autocomplete` passes through to the native field and defaults to `current-password`
- Labels, sizes, error state and focus rings match Input
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<!-- Login: masked field with visibility toggle -->
<arc-password-input label="Password" name="password" required></arc-password-input>
<!-- Sign-up: strength meter + password-manager generation -->
<arc-password-input
label="New password"
name="new-password"
autocomplete="new-password"
show-strength
required
></arc-password-input>
<script>
document.querySelector('[show-strength]').addEventListener('arc-strength-change', (e) => {
console.log('strength score:', e.detail.score); // 0-4
});
</script>import { PasswordInput } from '@arclux/arc-ui-react';
{/* Login */}
<PasswordInput label="Password" name="password" required />
{/* Sign-up with strength meter */}
<PasswordInput
label="New password"
name="new-password"
autocomplete="new-password"
showStrength
required
onArcStrengthChange={(e) => setScore(e.detail.score)}
/><script setup>
import { PasswordInput } from '@arclux/arc-ui-vue';
</script>
<template>
<!-- Login -->
<PasswordInput label="Password" name="password" required />
<!-- Sign-up with strength meter -->
<PasswordInput
label="New password"
name="new-password"
autocomplete="new-password"
show-strength
required
@arc-strength-change="(e) => console.log('strength score:', e.detail.score)"
/>
</template><script>
import { PasswordInput } from '@arclux/arc-ui-svelte';
</script>
<!-- Login -->
<PasswordInput label="Password" name="password" required />
<!-- Sign-up with strength meter -->
<PasswordInput
label="New password"
name="new-password"
autocomplete="new-password"
showStrength
required
on:arc-strength-change={(e) => console.log('strength score:', e.detail.score)}
/>import { Component } from '@angular/core';
import { PasswordInput } from '@arclux/arc-ui-angular';
@Component({
imports: [PasswordInput],
template: `
<!-- Login -->
<arc-password-input label="Password" name="password" required></arc-password-input>
<!-- Sign-up with strength meter -->
<arc-password-input
label="New password"
name="new-password"
autocomplete="new-password"
showStrength
required
(arcStrengthChange)="onStrength($event)"
></arc-password-input>
`,
})
export class PasswordFormComponent {
onStrength(e: CustomEvent) {
console.log('strength score:', e.detail.score);
}
}<div style="display:flex; flex-direction:column; width:100%; max-width:400px; gap:16px;">
<arc-password-input label="Password" name="password" required></arc-password-input>
<arc-password-input label="New password" name="new-password" autocomplete="new-password" show-strength required></arc-password-input>
</div>API
autoValidatesbooleanfalse- Runs its own constraint logic and owns the whole validity flag set.
namestring''- The
nameattribute sent with form data on submission. Also used by the Form component to track field state. labelstring''- Visible label rendered above the field. Automatically associated with the input via a generated id.
placeholderstring''- Hint text displayed when the field is empty. Use it for guidance, never as a substitute for the label.
valuestring''- The current value of the field. Can be set programmatically; updated internally on each keystroke.
disabledbooleanfalse- Prevents interaction (including the visibility toggle) and applies a muted visual treatment.
errorstring''- Error message displayed below the field. When set, the border turns red and the message is announced.
autocompletestring'current-password'- Passed through to the inner input. Use
new-passwordon registration or change-password forms so password managers offer generation. requiredbooleanfalse- Marks the field as required and enables native constraint validation on form submission.
size'sm' | 'md' | 'lg''md'- Controls the field size. Options: 'sm', 'md', 'lg'.
showStrengthbooleanfalse- Renders a four-segment strength meter with a Weak / Fair / Good / Strong label under the field, scored by a built-in heuristic (length, character variety, common-pattern penalties).
formAssociatedbooleantruepropertiesobject{ // flag(), unlike `disabled`. The exclusion in props.js is specifically // about form-associated *platform* semantics: a `disabled` content // attribute that is merely present makes the element actually disabled // per the HTML spec, and formDisabledCallback assigns the property back, // so no converter can win. Neither of these is platform-mapped: // `required` is enforced by _computeValidity() below and `readonly` by // each component's own interaction handlers, so the stock converter buys // nothing here and costs the usual bug: `required="false"` read as true, // blocking submission of a form the author meant to leave optional. // Finding #48's shape, across all 26 form controls at once. required: flag(false), readonly: flag(false), }- Lit merges static properties up the prototype chain, so every consumer
gets these without declaring them.
requiredparticipates in constraint validation below;readonlyreflects for styling and is enforced by each component's interaction handlers (the mixin can't know which gestures mutate state). formvalidityvalidationMessagereadonlybooleanfalse
Methods
checkValidity()boolean- Whether the control currently satisfies its constraints, per the native
constraint-validation API. Fires
invalidon the element when it does not, and reports nothing to the user. reportValidity()boolean- As checkValidity(), but also shows the browser's validation message against the control when it fails.
Events
arc-strength-change- Fired when the strength score changes (only while show-strength is set), with { score } detail (0-4)
arc-inputdetail:{ value: string }- Fired on each keystroke with { value } detail
arc-changedetail:{ value: string }- Fired on blur when value has changed, with { value } detail