Skip to content

InputOTP

<ax-input-otp> is a one-time-code field. A single hidden input handles paste and autofill, while the visible cells mirror its value. It implements ControlValueAccessor with two-way [(value)] and emits (complete) when all cells are filled.

import { AxInputOtpComponent } from '@axisui-ng/forms';
<ax-input-otp [length]="6" [(value)]="code" (complete)="verify($event)" />
<!-- masked, separator after index 3 (e.g. 3-3) -->
<ax-input-otp [length]="6" [separator]="3" mask [(value)]="code" />
InputTypeDefaultNotes
valuemodel<string>''Entered code ([(value)]); also CVA. Digits only; truncated to length.
lengthnumber6Number of cells / maxlength.
separatornumber | nullnullInsert a visual - before this cell index (e.g. 3 for a 3–3 split).
maskbooleanfalseRender instead of digits in the cells.
disabledbooleanfalseDisabled (also via CVA setDisabledState).
invalidbooleanfalseDestructive cell borders + aria-invalid on the hidden input.
describedBystring | nullnullaria-describedby on the hidden input (e.g. an error message id).
OutputPayloadNotes
completestringEmitted when value.length === length (and length > 0).

A real text input (opacity-hidden) underlies the cells, with inputmode="numeric" and autocomplete="one-time-code", so paste, autofill, and keyboard editing work. The input’s aria-label is "One-time code, N digits". Visible cells are aria-hidden; link helper/error text via describedBy.

Interactive examples live in Storybook under Forms / InputOTP. Run pnpm storybook to explore them.