Skip to content

✨ feat: add OtpInput and PasswordRules components - #734

Open
futjesus wants to merge 1 commit into
mainfrom
feat/otp-input-password-rules
Open

futjesus wants to merge 1 commit into
mainfrom
feat/otp-input-password-rules

Conversation

@futjesus

@futjesus futjesus commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

Dashboard-manager (signup VerifyCodeStep, PasswordRules) and settings (VerifyPhoneModal, PasswordRequirements) carry near-verbatim copies of a one-time-code input and a live password requirements list. The settings copy of the rules had lost its aria-live region.

  • OtpInput (new): one box per digit inside a fieldset named by label. The first box opts into SMS autofill (autocomplete="one-time-code", uncapped maxLength) and a pasted or autofilled code is spread across the boxes. Backspace on an empty box clears and focuses the previous one; ArrowLeft/ArrowRight move; non-digits are dropped. onChange on every change, onComplete when full; controlled (value) or uncontrolled (defaultValue); name renders a hidden input with the full code; error is announced with role="alert"; digitLabel localises each box.
  • PasswordRules (new): rules (id, label, test) evaluated against value in an aria-live region; each rule swaps a bullet for a check and appends a screen-reader status (metLabel / pendingLabel).
  • Both exported from the package root.

Test plan

  • OtpInput: group + autocomplete, typing advances and completes, non-digits ignored, paste spreads, Backspace/arrows, controlled value + hidden input, error announcement, axe
  • PasswordRules: statuses, updates on value change, custom labels, axe
  • npx vitest run lib/components/OtpInput lib/components/PasswordRules, lint, types, prettier
  • Storybook: OtpInput, PasswordRules

Dashboard-manager (signup VerifyCodeStep, PasswordRules) and settings
(VerifyPhoneModal, PasswordRequirements) carry near-verbatim copies of a
six-box one-time-code input and a live password requirements list; the
settings copy of the rules list had lost its live region.

OtpInput renders one box per digit inside a named fieldset. The first box
opts into SMS autofill with `autocomplete="one-time-code"` and an uncapped
maxLength, and a pasted or autofilled code is spread across the boxes;
Backspace on an empty box clears and focuses the previous one, the arrow
keys move between boxes, non-digits are dropped, and `onComplete` fires
once every digit is filled. Works controlled or uncontrolled and can carry
the code through a hidden input for native forms.

PasswordRules evaluates `rules` against `value` inside an `aria-live`
region, swapping a bullet for a check per rule and appending a
screen-reader status.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant