Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

InputOTP

Enter or paste a one-time code across accessible character cells.

Category
Forms and selection
Import
@neural-ui/core/input-otp
Selector
neu-input-otp
import { NeuInputOTPComponent } from '@neural-ui/core/input-otp';

Usage

length defines the number of cells and type chooses numeric or alphanumeric characters. The model remains one string. Pasting distributes characters across cells. completed reports a complete entry; verification against a server belongs to your application.

Examples

Interact with the example and open Code for its complete implementation.

Examples

Paste 123456 into the first cell. Backspace moves backwards; arrows move between cells. completed reports a full code but does not verify it.

Try and configure

Change the controls and try the live preview. Expand the application value or event to inspect its real data; the generated template stays with the configurator.

Try and configure

Live preview

Generated template: the options above. The Code tab contains the imports and state.

template.html
<neu-input-otp
  [(value)]="text"
  [length]="6"
  type="numeric"
  [ariaLabel]="'Verification code'"
/>

Signal Forms

Bind FormField once to the component; the field owns value and validation. The schema requires six characters; completed is an event, not a validator. Leave the control to mark it touched, then reset the field to clear both value and interaction state.

Signal Forms guide

Signal Forms

Valid: false

Value and events

Use [(value)] or [value] with (valueChange), not both. The model synchronizes application state; other Outputs communicate their documented events. touch reports leaving/visiting the control, not a new value.

Accessibility and keyboard

Set ariaLabel to name the whole verification code. Each cell has its own position label; the application locale controls its language. Pasting fills successive cells, ArrowLeft/ArrowRight changes focus and Home/End moves to an endpoint. Show verification feedback separately from the completed event.

Key
Action
Tab Enters and leaves the control.
ArrowLeft / ArrowRight Moves between character cells.
Backspace Clears a cell or moves backwards.

API

Inputs, models and Outputs come from the pinned Core contract. Click named types to open their definitions. This component has no public template slots.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
ariaLabelstring'One-time code'[ariaLabel]Accessible name when no visible label is available.
dirtybooleanfalse[dirty]Form state indicating that the user has changed the value.
disabledbooleanfalse[disabled]Prevents user interaction.
errorsreadonly ValidationError.WithOptionalFieldTree[][][errors]Validation errors supplied by the form or the application.
hiddenbooleanfalse[hidden]Hides the control according to the form state.
inputIdstringinject(NeuIdGenerator).getId('neu-input-otp-')Derived default[inputId]Stable identifier of the native control; automatically generated when omitted.
invalidbooleanfalse[invalid]Displays the invalid state; it does not add a validation rule.
lengthnumber6[length]Number of OTP character cells.
maxLengthnumber | undefinedundefined[maxLength]Form-supplied maximum string length. Configure the validator in your form schema.
minLengthnumber | undefinedundefined[minLength]Form-supplied minimum string length. Configure the validator in your form schema.
namestring''[name]Name associated with the native form control.
pendingbooleanfalse[pending]Form state indicating that asynchronous validation is pending.
readonlybooleanfalse[readonly]Keeps the control focusable and readable without accepting edits.
requiredbooleanfalse[required]Marks the field as required; use a form validator to enforce it.
touchedbooleanfalse[touched]Form state indicating that the control has been visited.
type"numeric" | "alphanumeric"'numeric'[type]numeric allows digits; alphanumeric also allows letters.

Models

A model supports [(property)]="signal" or the [property] and (propertyChange) pair. Choose one form, not both.

Name
Type
Default
Template binding
Description
valuestring''[(value)]Single committed string, synchronized through valueChange.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
completedstring(completed)="onCompleted($event)"Emits the normalized full code after all cells are filled; does not authenticate it.
touchvoid(touch)="onTouch($event)"Notifies the form that the control has been touched; not a value change.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

This component does not expose content projection or public customization templates.

Styles and tokens

Load Core styles once. Use the public tokens below for local customization or a preset for application-wide changes. Keep labels, focus, selected options and disabled states readable in both light and dark themes.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-focus-ring-alpha Opacity of the semantic focus ring Shared by other Core consumers; scope the override. 25%
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-radius Control corner radius Shared by other Core consumers; scope the override. 8px
--neu-border-color Inherited theme value used by this component Shared by other Core consumers; scope the override. var(--neu-border)
--neu-otp-cell-bg Inherited theme value used by this component Shared by other Core consumers; scope the override. var(--neu-surface-1)
--neu-otp-cell-border Inherited theme value used by this component Shared by other Core consumers; scope the override. var(--neu-border)
--neu-otp-cell-radius Corner radius Shared by other Core consumers; scope the override. var(--neu-radius)
--neu-otp-cell-size Inherited theme value used by this component Shared by other Core consumers; scope the override. 2.75rem