One-time code inputs
Capture numeric verification codes in a single accessible field with a clear length constraint.
Live preview
Six numbers only; pasting a code works.
HTML
<div class="xsh-field xsh-measure">
<label class="xsh-label" for="xsh-otp">Six-digit verification code</label>
<input class="xsh-input xsh-otp" id="xsh-otp" type="text" inputmode="numeric" pattern="[0-9]{6}" data-xsh-otp-length="6" autocomplete="one-time-code" placeholder="000000" aria-describedby="xsh-otp-help" data-xsh-digits>
<small class="xsh-help" id="xsh-otp-help">Six numbers only; pasting a code works.</small>
</div>Installation & markup
Include the local stylesheet and script once on the page, then place the component inside a data-xsh-ui root. The example above works without a build system.
<link rel="stylesheet" href="/dist/xshna-ui.css">
<div data-xsh-ui>
<!-- Add the HTML example above -->
</div>
<script defer src="/dist/xshna-ui.js"></script>Component API
Public classes, attributes and hooks used by this example. Keep the xsh- prefix intact.
| Identifier | Contract |
|---|---|
xsh-otp | Used by the example markup and component styles or behavior. |
data-xsh-digits | Used by the example markup and component styles or behavior. |
inputmode | Used by the example markup and component styles or behavior. |
pattern | Used by the example markup and component styles or behavior. |
Accessibility & keyboard
Typing or pasting strips nonnumeric characters. Tab reaches the next control.
Implementation note. Single-field OTP avoids the focus traps and paste problems of multiple input boxes.
Interaction contract
Behavioral components use the shared delegated runtime; visual-only primitives rely on semantic HTML and CSS. Runtime controls emit bubbling xsh:* CustomEvents; bind application handlers to those events when server persistence, API data or navigation is required.