OTP Input
Design System - OTP input component
The OTP Input component is designed to collect secure, time-sensitive verification codes from users in a clear and accessible way. It emphasises clarity, accuracy, and ease of use across different devices, ensuring a smooth authentication process.

// Sample code
<CheckBox
label="Label"
onChange={(e)=>{console.log(e.target.checked}}
/>
Anatomy

Variants

4-characters
Used when the OTP is limited to four digits, offering a compact layout ideal for simpler authentication flows.

6-characters
Common in more secure flows, this variant provides six input boxes for enhanced verification.
Properties
Label Positioned above the input fields (e.g., "Enter OTP"), it provides clear instructions to the user.

Error Displays an error message (e.g., “Invalid OTP”) with a red border and icon to indicate incorrect input.

Masking
Optionally replaces typed characters with dots (●) for added security, particularly useful in shared or public environments.

Property Configuration Table
Each design component offers a range of configurable options. These options are intentionally platform-agnostic, allowing implementations to adapt and tailor them to align with the specific requirements of the chosen framework.
length
text
-
type
text
no
onChange
yes/no
no
placeholder
yes/no
-
className
number
-
style
yes/no
-
label
yes/no
no
inline
yes/no
no
masking
yes/no
no
Interaction State
Single Focus In Single Focus mode, only one input box is actively focused at a time. As the user types, the focus automatically moves to the next box, improving usability and reducing the need for manual navigation between fields.

Behaviours

Auto Tabbing
The cursor automatically jumps to the next field as each digit is entered.

Backspace Navigation
Pressing backspace in an empty field moves the focus to the previous box, allowing easy correction.

Paste Handling
Supports pasting a full OTP string, automatically distributing characters across input fields.
Usage Guide

Use Clear Focus State for Better User Guidance
Ensure that the currently active OTP input field is visually distinct so users can immediately recognise where they need to type next. A proper focus state improves accessibility and enhances the user experience by providing clear feedback on input interactions. Users should not struggle to identify which input box is currently active. Lack of clear focus indication can result in hesitation or mistakes, causing frustration.

Changelog
Dec 15, 2024
v-0.0.2
This component is added to the website. This component is now individually versioned.
Design Checklist
All interactive states - Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).
Accessible use of colours - Colour is not used as the only visual means of conveying information (WCAG 2.1 1.4.1)
Accessible contrast for text - Text has a contrast ratio of at least 4.5:1 for small text and at least 3:1 for large text (WCAG 2.0 1.4.3).
Accessible contrast for UI components - Visual information required to identify components and states (except inactive components) has a contrast ratio of at least 3:1 (WCAG 2.1 1.4.11).
Keyboard interactions - Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).
Screen reader accessible - All content, including headings, labels, and descriptions, is meaningful, concise, contextual and accessible by screen readers.
Responsive for all breakpoints - Responsiveness for 3 breakpoints - Mobile, Tablet and Desktop
Usage guidelines - Includes a list of dos and don'ts that highlight best practices and common mistakes.
Content guidelines - Content standards and usage guidelines for writing and formatting in-product content for the component.
Defined variants and properties - Includes relevant variants and properties (style, size, orientation, optional iconography, decorative elements, selection states, error states, etc.)
Defined behaviours - Guidelines for keyboard navigation and focus, layout management (including wrapping, truncation, and overflow), animations, and user interactions.
Design Kit - Access to the design file for the component in Figma, multiple options, states, colour themes, and platform scales.
Last updated
Was this helpful?