cv-code-input
Segmented short-code entry for PIN, OTP, pairing, and recovery codes.
Headless: createCodeInput
Usage
Markup Patterns
html
<!-- Numeric one-time code with native mobile autocomplete on the first segment -->
<cv-code-input purpose="otp" length="6" required autocomplete="one-time-code"></cv-code-input>
<!-- Masked local PIN -->
<cv-code-input purpose="pin" length="4" mask name="pin"></cv-code-input>
<!-- Alphanumeric device pairing token -->
<cv-code-input purpose="pairing" charset="alphanumeric" length="6" name="pairingCode"></cv-code-input>
<!-- Recovery code with an external validation error -->
<cv-code-input purpose="recovery" charset="alphanumeric" length="6" value="A7K2M9" invalid></cv-code-input>Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
length | Number | 6 | Segment count |
value | String | "" | Normalized code value |
purpose | pin | otp | pairing | recovery | otp | Semantic input purpose |
charset | numeric | alphanumeric | numeric | Accepted character set |
mask | Boolean | false | Masks visible segment values |
disabled | Boolean | false | Blocks interaction |
readonly | Boolean | false | Blocks editing but keeps focus |
required | Boolean | false | Form validation required flag |
invalid | Boolean | false | Marks segments as invalid |
autocomplete | String | purpose-based | Native autocomplete hint |
name | String | "" | Form name |
size | small | medium | large | medium | Segment size |
Events
| Event | Detail |
|---|---|
cv-input | { value, complete } |
cv-change | { value, complete } |
cv-complete | { value, complete } |