r/javascript • u/javiOrtega95 • Apr 17 '26
I built a headless, accessible PIN/OTP input Web Component
javierortega95.github.ioI needed a PIN/OTP input for a project and most solutions I found were either tied to a specific framework, heavily opinionated about styling, or both. So I built my own as a native Web Component.
It supports:
- Fully customizable via ::part() — no style overrides, no specificity battles
- Smart paste — distributes pasted text across slots automatically
- SMS Autofill — autocomplete="one-time-code" out of the box
- Native form participation — works with <form>, FormData and HTML5 validation
- Mask mode — hides characters like a password field
- Separators — configurable slot grouping (e.g. 123-456)
- Full keyboard navigation and screen reader support
- React, Vue, Angular and Vanilla JS tested and working