Password Field
A password input with a show/hide toggle, a strength meter, a requirements checklist and a Caps Lock warning.
c2-password-field is the password input of sign-in and sign-up forms. The eye button at the end of the field shows the password in clear text and hides it again, returning focus to the field; it is a toggle button (aria-pressed) named by toggle-label, the element’s revealed property follows it and reveal-change reports it. hide-toggle removes the button. While Caps Lock is on and the password is hidden, a warning shows under the field (caps-lock-text, empty to turn it off).
For a new password, set autocomplete="new-password" and add guidance. meter shows a four-segment strength meter labelled by strength-labels (Too weak;Weak;Fair;Good;Strong), fires strength-change when the score moves, and sets :state(strength-0) to :state(strength-4) on the host. The default estimate weighs length and character variety and rejects common passwords; it is a hint for the user, so hand scorer a function returning 0–4 (zxcvbn, for instance) when the score matters. requirements adds a checklist that ticks each rule as it is met: length (at least minlength, 8 by default), lowercase, uppercase, number and symbol, separated by semicolons. From script, an entry can also be an object: { id: 'number', label: 'Eine Ziffer' } translates a built-in rule, and { label, pattern } or { label, test } adds one of your own. While a requirement is unmet, the strength is capped at Weak.
The element is form-associated: name submits the password with its form, and it validates like an input (required, minlength, maxlength), plus every requirement once something is typed (requirements-message). error with error-text shows a server-side error such as a wrong password; help is the plain helper line. Give the host a width and the field fills it.
Import
import '@c2n/components/password-field'Usage
- At least 10 characters, not met
- One uppercase letter, not met
- One number, not met
- One symbol, not met