Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
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
| Input | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Unique identifier used to connect the input parts. |
name | string | undefined | — | Sets the hidden input name used during form submission. |
form | string | undefined | — | Associates the hidden input with a form by ID. |
pattern | string | undefined | — | Restricts accepted characters with a regular-expression pattern. |
ids | PinInputElementIds | undefined | — | Overrides generated identifiers for individual parts. |
disabled | boolean | false | Disables the input and all character slots. |
placeholder | string | undefined | — | Sets the placeholder character displayed by empty slots. |
autoFocus | boolean | false | Focuses the first available slot when initialized. |
invalid | boolean | false | Marks the input as invalid. |
required | boolean | false | Marks the hidden form input as required. |
readOnly | boolean | false | Prevents changes while preserving focus and navigation. |
otp | boolean | false | Enables one-time-password input behavior. |
value | string[] | undefined | — | Controls the current array of entered characters. |
defaultValue | string[] | undefined | — | Sets the initial value when value is uncontrolled. |
type | "alphanumeric" | "numeric" | "alphabetic" | undefined | — | Restricts the general category of accepted characters. |
mask | boolean | false | Masks the entered characters. |
autoSubmit | boolean | false | Submits the associated form when all slots are complete. |
blurOnComplete | boolean | false | Blurs the active slot when all slots are complete. |
selectOnFocus | boolean | false | Selects a slot's text when it receives focus. |
sanitizeValue | ((value: string) => string) | undefined | — | Transforms entered or pasted text before it is stored. |
translations | PinInputIntlTranslations | undefined | — | Overrides accessible labels used by the input. |
count | number | undefined | registered slots | Overrides the number of slots derived from slot registration. |
Outputs
| Output | Event type | Description |
|---|---|---|
valueChange | string[] | undefined | Emits when the value model changes. |
valueComplete | PinInputValueChangeDetails | Emits when every slot contains a valid character. |
valueDetailsChange | PinInputValueChangeDetails | Emits details whenever the value changes. |
valueInvalid | PinInputValueInvalidDetails | Emits when entered or pasted text contains invalid data. |
input[appInputOtpSlot]
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
index | number | required | Zero-based position of this slot within the complete value. |
Native input attributes, properties, and events remain available on the slot.
Context, Providers, and Utilities
| Export | Angular API |
|---|---|
PinInputContext | Structural directive that exposes the nearest signal-backed API to a template. |
PinInputRootProvider | Directive 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. |
InputOTPImports | Readonly collection containing the wrapper UI and context directives. |
Types
| Export | Description |
|---|---|
PinInputApi | Reactive API exposed by the Pin Input machine. |
PinInputElementIds | Identifiers for the Pin Input parts. |
PinInputIntlTranslations | Accessible label translations accepted by the input. |
PinInputValueChangeDetails | Details emitted for value changes and completion. |
PinInputValueInvalidDetails | Details emitted when invalid text is entered or pasted. |
UsePinInputProps | Configuration accepted by usePinInput. |
UsePinInputOptions | Angular context options passed to usePinInput. |
UsePinInputReturn | Signal-backed state, machine service, and input API. |
Angular
React
Solid
Svelte
Vue