OTP / PIN Input
A segmented verification code control that splits fixed-length OTP or PIN digits into visual slots with auto-advance, full-code paste, and SMS autofill
Table of Contents
Interactive Playground
Tap or drag to interact with the demoWhat is OTP / PIN Input?
A segmented verification code control that splits fixed-length OTP or PIN digits into visual slots with auto-advance, full-code paste, and SMS autofill. It is a core concept in UI Components within UI / UX.
Core Principles
An OTP / PIN Input displays a fixed-length verification code (typically 4–6 digits) as discrete visual slots. Seeing exact slot count reduces entry errors, while auto-advancing focus and optional auto-submission make verification effortless.
Although rendered as separate boxes, modern web implementations increasingly back the UI with a single underlying <input> overlaid with styled slots. This avoids fragile multi-input focus hacks and makes clipboard pasting, selection, and OS autofill rock-solid.
Practical Takeaways
- Support full-code paste and smooth Backspace: Pasting
123456(or123-456) into any slot should strip non-digits and populate every box; pressing Backspace on an empty slot should step backward and clear the previous digit. - Enable native mobile keyboards and SMS autofill: Always set
inputMode="numeric"andautoComplete="one-time-code"so mobile devices open the numeric keypad and surface one-tap SMS code suggestions. - Design graceful error recovery: On an invalid code, show an inline error, clear or highlight the code for quick retry, and pair the field with an expiration timer and resend cooldown.
Notable Examples
- Two-factor authentication (2FA): 6-digit SMS or authenticator app verification in banking and SaaS logins.
- Fintech payment PINs: Masked 6-dot PIN entry screens for instant transfers.
- Device pairing codes: Grouped
3 + 3alphanumeric slots for linking smart TVs or desktop apps.