@objectifthunes/whiteboard
FORMS

PasswordField

Password input with a reveal toggle and an optional strength meter. Use the meter on sign-up, never on sign-in.


PREVIEW
Good

At least 12 characters.

Needs at least 8 characters.

estimatePasswordStrength("correct horse battery") → score 3, "Good"
SOURCE
import { PasswordField } from '@objectifthunes/whiteboard'

{/* sign-in: no meter */}
<PasswordField
  label="Password"
  value={password}
  onChange={e => setPassword(e.target.value)}
  autoComplete="current-password"
/>

{/* sign-up: meter on */}
<PasswordField
  label="Choose a password"
  hint="At least 12 characters."
  showStrength
  value={password}
  onChange={e => setPassword(e.target.value)}
  autoComplete="new-password"
/>
NOTES

Reveal exists because forcing people to retype a password they cannot see is how you get typos and abandoned sign-ups. The toggle is a real button with an aria-label and aria-pressed, so it is reachable by keyboard and announced properly.

Use showStrength on sign-up and password-reset only. On sign-in it would be rating a password the user already has, which is noise.

estimatePasswordStrength weights length first, then character variety, because length is what actually resists guessing. It is a hint for the user, not a security control — real policy belongs on the server where it cannot be skipped. It is exported so you can drive your own submit-disabled logic from the same score the user sees.

Remember autoComplete: current-password on sign-in, new-password on sign-up. Getting these wrong is why password managers save the wrong thing.