Search documentation

Search the documentation and open a page.

Displays a one-time password input with individual character slots.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/input-otp

Composition

<app-input-otp> ├── [appInputOtpLabel] (optional) ├── [appInputOtpGroup] │ └── input[appInputOtpSlot] ├── [appInputOtpSeparator] (optional, between groups) └── [appInputOtpGroup] (optional, additional group) └── input[appInputOtpSlot]

Examples

Cells

Loading...

Default

Loading...

Digits Only

Loading...

Separator

Loading...

API Reference

<app-input-otp>

The component renders the control wrapper and hidden form input internally. It implements ControlValueAccessor, so it can also be used with Angular forms.

Inputs

InputTypeDefaultDescription
idstring | undefinedgeneratedUnique identifier used to connect the input parts.
namestring | undefined—Sets the hidden input name used during form submission.
formstring | undefined—Associates the hidden input with a form by ID.
patternstring | undefined—Restricts accepted characters with a regular-expression pattern.
idsPinInputElementIds | undefined—Overrides generated identifiers for individual parts.
disabledbooleanfalseDisables the input and all character slots.
placeholderstring | undefined—Sets the placeholder character displayed by empty slots.
autoFocusbooleanfalseFocuses the first available slot when initialized.
invalidbooleanfalseMarks the input as invalid.
requiredbooleanfalseMarks the hidden form input as required.
readOnlybooleanfalsePrevents changes while preserving focus and navigation.
otpbooleanfalseEnables one-time-password input behavior.
valuestring[] | undefined—Controls the current array of entered characters.
defaultValuestring[] | undefined—Sets the initial value when value is uncontrolled.
type"alphanumeric" | "numeric" | "alphabetic" | undefined—Restricts the general category of accepted characters.
maskbooleanfalseMasks the entered characters.
autoSubmitbooleanfalseSubmits the associated form when all slots are complete.
blurOnCompletebooleanfalseBlurs the active slot when all slots are complete.
selectOnFocusbooleanfalseSelects a slot's text when it receives focus.
sanitizeValue((value: string) => string) | undefined—Transforms entered or pasted text before it is stored.
translationsPinInputIntlTranslations | undefined—Overrides accessible labels used by the input.
countnumber | undefinedregistered slotsOverrides the number of slots derived from slot registration.

Outputs

OutputEvent typeDescription
valueChangestring[] | undefinedEmits when the value model changes.
valueCompletePinInputValueChangeDetailsEmits when every slot contains a valid character.
valueDetailsChangePinInputValueChangeDetailsEmits details whenever the value changes.
valueInvalidPinInputValueInvalidDetailsEmits when entered or pasted text contains invalid data.

input[appInputOtpSlot]

Inputs

InputTypeDefaultDescription
indexnumberrequiredZero-based position of this slot within the complete value.

Native input attributes, properties, and events remain available on the slot.

Context, Providers, and Utilities

ExportAngular API
PinInputContextStructural directive that exposes the nearest signal-backed API to a template.
PinInputRootProviderDirective that provides an external API through its required value input.
usePinInput(options)Creates the signal-backed input API inside an Angular injection context.
injectPinInputContext()Injects the nearest Pin Input context.
InputOTPImportsReadonly collection containing the wrapper UI and context directives.

Types

ExportDescription
PinInputApiReactive API exposed by the Pin Input machine.
PinInputElementIdsIdentifiers for the Pin Input parts.
PinInputIntlTranslationsAccessible label translations accepted by the input.
PinInputValueChangeDetailsDetails emitted for value changes and completion.
PinInputValueInvalidDetailsDetails emitted when invalid text is entered or pasted.
UsePinInputPropsConfiguration accepted by usePinInput.
UsePinInputOptionsAngular context options passed to usePinInput.
UsePinInputReturnSignal-backed state, machine service, and input API.