CoreUI Angular Logo
Framework:
  • JavaScript / Vanilla JS
  • React.js
  • Vue.js
Getting startedIntroductionSupport CoreUICustomizeSassOptionsCSS VariablesLayoutBreakpointsContainersGridColumnsGuttersFormsOverviewAutocompletePRODate PickerPRODate Range PickerPROForm ControlSelectMulti SelectPROChecks & RadiosOTP InputPROPassword InputPRORangeRange SliderPRORatingPROStepperPROInput GroupFloating LabelsLayoutTime PickerPROValidationComponentsAccordionAlertAvatarBadgeBreadcrumbButtonButton GroupCalendarPROCalloutCardCarouselClose buttonCollapseDropdownFooterHeaderImageList GroupLoading ButtonPROModalNavNavbarOffcanvasPaginationPlaceholderPopoverProgressSmart PaginationPROSmart TablePROSidebarSpinnerTableTabsNewToastTooltipWidgetsIconsChartsTemplatesNewAdmin & DashboardDownloadInstallationCustomizeContentMigrationv4 → v5v3 → v4Angular version
Pricing


DownloadHire UsGet CoreUI PRO
On this page

Component Preview Pro v5.5.23+

Please note that the API for this component is currently in development and may be subject to changes.

CoreUI PRO for Angular This component is part of CoreUI PRO – a powerful UI library with over 250 components and 25+ templates, designed to help you build modern, responsive apps faster. Fully compatible with Angular, Bootstrap, React.js, and Vue.js. Get CoreUI PRO

Angular One Time Password (OTP) Input Component

Develop secure and user-friendly Angular one-time password input fields with automatic navigation, paste support, validation, and customizable options for modern authentication flows.

Introduced in Pro v5.5.23+

Example

The c-one-time-password component and cOtp directive are perfect for creating secure Angular OTP input fields. They offer automatic character navigation and validation, making them ideal for two-factor authentication, SMS verification codes, and secure login flows.

Current value:
Loading...
Loading...

One-time password types

The one-time password input supports various input types for different use cases.

Loading...
Loading...

Placeholders

Provide visual cues to users by displaying placeholder text in the input fields for OTP. You can use a single character for all fields or specify different placeholders for each field.

Loading...
Loading...

Pre-filled values

Set initial values using the value prop.

Loading...
Loading...

Input modes

Control user input behavior with linear and non-linear modes.

Loading...
Loading...

Auto-submit

Enable automatic form submission when all one-time password fields are completed.

Loading...
Loading...

Custom layouts

Create custom one-time password layouts with separators and different field counts.

-
•
•
Loading...
Loading...

Sizing variants

One-time password input supports different sizes. You may choose from small, normal (default), and large inputs to match our similarly sized text inputs.

Loading...
Loading...

Disabled state

Disable the entire one-time password input by adding the disabled prop.

Loading...
Loading...

Readonly state

Use the readOnly prop to make the one-time password input non-editable but still selectable.

Loading...
Loading...

Validation state

Use the valid prop to indicate input validity.

Loading...
Loading...

Forms

Angular handles user input through reactive and template-driven forms. CoreUI One Time Password OTP Input for Angular supports both approaches.

Reactive

The Angular OTP Input component can be used with reactive forms. You can bind the OTP Input value to a form control using the formControlName directive.

Current value: { "otp": "" }
Loading...
Loading...

Template-driven

The Angular OTP Input component can be used in template-driven forms. You can bind the value to a template variable using the ngModel directive.

Current value: { "otp": "" }
Loading...
Loading...

Accessibility (a11y)

The one-time password input component is designed with accessibility in mind and follows WCAG guidelines for form inputs.

  • ARIA Labels: Each input field automatically receives descriptive aria-label attributes
  • Role Attribute: The container has role="group" to indicate related form controls
  • Keyboard Navigation: Full keyboard support with arrow keys, tab, and backspace
  • Screen Reader Support: Clear announcements when values change or validation occurs
  • Focus Management: Automatic focus handling for seamless navigation

Customizing accessibility

You can customize the aria-label generation function to provide more specific descriptions:


const ariaLabel = (index, total) => `Enter digit ${index + 1} of your ${total}-digit verification code`

Keyboard support

The one-time password input component provides comprehensive keyboard navigation support:

Key Action
ArrowLeft Moves focus to previous field
ArrowRight Moves focus to next field
Backspace Delete current character or move to a previous field (if empty)
Tab Move to next focusable element (respects linear mode)
Shift + Tab Move to previous focusable element
Ctrl + V / Cmd + V Paste clipboard content and auto-fill fields

Customizing

CSS Classes

The One Time Password Input components use the following CSS classes:

  • .form-otp - Applied to the wrapper container
  • .form-otp-sm - Small size variant
  • .form-otp-lg - Large size variant
  • .form-otp-control - Applied to individual input elements

SASS variables


API reference

OTP Module

OTP Standalone

c-one-time-password

component


Inputs
name description type default
ariaLabel Function to generate aria-label for each input field. Receives current index (0-based) and total number of inputs. (index: number, total: number) => string `(index: number, total: number) => 'Digit ${index + 1} of ${total}'
autoSubmit Automatically submit the form when all one time password fields are filled. boolean false
defaultValue Initial value for one time password input. string | number ''
disabled Disable all one time password (OTP) input fields. boolean false
valid OTP input validation state. boolean | undefined undefined
linear Ensure that users fill in the fields in a sequential order. boolean true
masked Display the input as a password (with masked characters). boolean false
placeholder Placeholder text for input fields. Single character applies to all fields, longer strings apply character-by-character. string ''
readOnly Make Angular OTP input component read-only. boolean false
sizing Sets the visual size of the Angular one time password (OTP) input. Use sm for small or lg for large input fields. sm | lg ''
type Input validation type: number for digits only, or text for free text. number | text number
value Calue for OTP input. number | string ''
Outputs
name description type
valueChange Event triggered when the Angular one time password (OTP) value changes. string
complete Emits an event when all Angular one time password (OTP) fields are filled void

input[cOtp]

directive


  • GitHub
  • Twitter
  • Support
  • CoreUI (Vanilla)
  • CoreUI for React.js
  • CoreUI for Vue.js

CoreUI for Angular is Open Source UI Components Library for Angular.

Currently v5.5.24 Code licensed MIT , docs CC BY 3.0 .
CoreUI PRO requires a commercial license.