OTP Input
Form-associated one-time-code field with one cell per character, paste and SMS autofill, grouping and masking.
c2-otp-input collects a verification code as a row of cells. One native input sits over the cells, so typing, Backspace, pasting a whole code and SMS or password-manager autofill (autocomplete="one-time-code") behave natively and screen readers announce a single text box. Set length for the number of cells, mode="alphanumeric" to accept letters, group to split the cells with a separator, and masked to hide what was typed. The element fires complete once every cell is filled, and reports tooShort validity for a partial code.
Import
import '@c2n/components/otp-input'Usage
The value only ever holds accepted characters, cut to length: in the default numeric mode a pasted 123-456 becomes 123456. The caret always sits after the last character, so Backspace removes characters from the end. complete fires only for user input, with the code in detail.value; setting value from script does not fire it.