OTP Field #88
Labels
📦 core-component
A component composable
🍰 p3-low
Tasks that are nice-to-have. Like minor bugs, non-essential features, or cosmetic changes.
🌟 ver-minor
PR should have a minor version changeset type
Milestone
What
OTP inputs are tricky to build and naturally, they have multiple requirements and expectations.
The OTP input should have the following features:
length
prop?Anatomy
There are two ways to build an OTP input, I do not think we should support both since they are wildly different.
Single Input Field
Easier to manage and fill as it is only 1 field.
Validation will be easy to implement, but patterns will require some logic to prevent illegal characters.
You could style it to look like it has code boxes like in this article, but I do not think it feels nice at all and it is magic-number heavy.
Multi-input Fields
Each field would represent one code character, most UI libraries implement this pattern as it is more visually appealing and does inform the user about the length of the expected code implicitly.
I think this is the approach we should follow, I do not know about the a11y concerns around this.
Examples:
Extras
Web OTP API
This can be very useful for mobile devices, right now it is only supported on Chrome/Edge and their mobile counterparts, but we can support it regardless.
Resources
The text was updated successfully, but these errors were encountered: