OTP Input Component: Complete Checklist
The complete checklist for building an OTP input in a machine coding interview.
OTP Input Component: Complete Checklist
Here is the complete checklist for building an OTP input in a machine coding interview.
Core Features
- 4-6 input elements with
maxlength="1". - Auto-focus to the next input on digit entry.
- Backspace to the previous input (when current is empty).
- Only numeric input (regex filter).
- Verify button (enabled when all inputs are filled).
Advanced Features
- Paste support (fill multiple inputs from clipboard).
- Arrow key navigation (left/right).
- Enter key to submit when complete.
- Error state (red border on invalid OTP).
- Clear inputs on error and focus the first.
- Resend OTP with countdown timer.
Accessibility
-
role="group"andaria-labelon the container. -
aria-label="Digit N"on each input. -
inputmode="numeric"for mobile numeric keyboard. -
autocomplete="one-time-code"for iOS auto-fill. - Focus the first input on page load.
- Screen reader announcements (aria-live).
CSS
- Flexbox layout (horizontal, gap between inputs).
- Fixed width and height for each input.
- Large font size (24px+) for digits.
- Center-aligned text.
- Border and border-radius.
- Focus styling (border color, box-shadow).
- Error styling (red border).
Testing
- Test: type digits (auto-focus works).
- Test: backspace (goes to previous).
- Test: paste (fills all inputs).
- Test: non-numeric input (filtered out).
- Test: arrow keys (navigation works).
- Test: verify button (enables when complete).
- Test: keyboard only (no mouse).
- Test: mobile (numeric keyboard shows).
Time Allocation
- Core: 40 minutes.
- Advanced: 20 minutes.
- CSS: 10 minutes.
- Testing: 10 minutes.
- Buffer: 10 minutes.
The Takeaway
Checklist: core (auto-focus, backspace, numeric, verify button), advanced (paste, arrows, error, resend), accessibility (ARIA, inputmode, autocomplete), CSS (flexbox, focus styling), and testing (all features and keyboard). Time: 40 min core, 20 min advanced, 10 min CSS, 10 min testing.
Core (auto-focus, backspace, numeric filter, verify button), advanced (paste, arrows, error state, resend), accessibility (ARIA, inputmode, autocomplete), CSS (flexbox, focus styling), and testing (all features and keyboard). Allocate 40 min core, 20 min advanced, 10 min CSS, 10 min testing.
Auto-focus to next on digit entry, backspace to previous when empty, numeric-only input, and a verify button that enables when all inputs are filled. These are the minimum required features.
role='group' and aria-label on the container. aria-label='Digit N' on each input. inputmode='numeric' for mobile. autocomplete='one-time-code' for iOS. Focus the first input on load. Screen reader announcements with aria-live.
Test typing digits (auto-focus), backspace (goes to previous), paste (fills all), non-numeric input (filtered), arrow keys (navigation), verify button (enables when complete), keyboard only (no mouse), and mobile (numeric keyboard).
Core (auto-focus, backspace, numeric, verify): 40 min. Advanced (paste, arrows, error, resend): 20 min. CSS (layout, focus, error styling): 10 min. Testing: 10 min. Buffer: 10 min. Total: 90 min.
Ready to master React completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master React
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

