Skip to main content
Version: v8

ion-input-otp

scoped

The Input OTP component is a specialized input component designed for entering one-time passwords (OTP). It provides a user-friendly interface for entering verification codes with support for multiple input fields and automatic focus management.

Basic Usage

Type

Shape

Fill

Size

Separators

States

Pattern

Theming

Colors

CSS Properties

Properties

autocapitalize

DescriptionIndicates whether and how the text value should be automatically capitalized as it is entered/edited by the user. Available options: "off", "none", "on", "sentences", "words", "characters".
Attributeautocapitalize
Typestring
Default'off'

color

DescriptionThe color to use from your application's color palette. Default options are: "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark". For more information on colors, see theming.
Attributecolor
Type"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string | undefined
Defaultundefined

disabled

DescriptionIf true, the user cannot interact with the input.
Attributedisabled
Typeboolean
Defaultfalse

fill

DescriptionThe fill for the input boxes. If "solid" the input boxes will have a background. If "outline" the input boxes will be transparent with a border.
Attributefill
Type"outline" | "solid" | undefined
Default'outline'

inputmode

DescriptionA hint to the browser for which keyboard to display. Possible values: "none", "text", "tel", "url", "email", "numeric", "decimal", and "search".

For numbers (type="number"): "numeric" For text (type="text"): "text"
Attributeinputmode
Type"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url" | undefined
Defaultundefined

length

DescriptionThe number of input boxes to display.
Attributelength
Typenumber
Default4

pattern

DescriptionA regex pattern string for allowed characters. Defaults based on type.

For numbers (type="number"): "[0-9]" For text (type="text"): "[a-zA-Z0-9]"
Attributepattern
Typestring | undefined
Defaultundefined

readonly

DescriptionIf true, the user cannot modify the value.
Attributereadonly
Typeboolean
Defaultfalse

separators

DescriptionWhere separators should be shown between input boxes. Can be a comma-separated string or an array of numbers.

For example: "3" will show a separator after the 3rd input box. [1,4] will show a separator after the 1st and 4th input boxes. "all" will show a separator between every input box.
Attributeseparators
Typenumber[] | string | undefined
Defaultundefined

shape

DescriptionThe shape of the input boxes. If "round" they will have an increased border radius. If "rectangular" they will have no border radius. If "soft" they will have a soft border radius.
Attributeshape
Type"rectangular" | "round" | "soft"
Default'round'

size

DescriptionThe size of the input boxes.
Attributesize
Type"large" | "medium" | "small"
Default'medium'

type

DescriptionThe type of input allowed in the input boxes.
Attributetype
Type"number" | "text"
Default'number'

value

DescriptionThe value of the input group.
Attributevalue
Typenull | number | string | undefined
Default''

Events

NameDescriptionBubbles
ionBlurEmitted when the input group loses focus.true
ionChangeThe ionChange event is fired when the user modifies the input's value. Unlike the ionInput event, the ionChange event is only fired when changes are committed, not as the user types.

The ionChange event fires when the <ion-input-otp> component loses focus after its value has changed.

This event will not emit when programmatically setting the value property.
true
ionCompleteEmitted when all input boxes have been filled with valid values.true
ionFocusEmitted when the input group has focus.true
ionInputThe ionInput event is fired each time the user modifies the input's value. Unlike the ionChange event, the ionInput event is fired for each alteration to the input's value. This typically happens for each keystroke as the user types.

For elements that accept text input (type=text, type=tel, etc.), the interface is InputEvent; for others, the interface is Event. If the input is cleared on edit, the type is null.
true

Methods

reset

DescriptionResets the input values and focus state.
Signaturereset() => Promise<void>

setFocus

DescriptionSets focus to an input box.
SignaturesetFocus(index?: number) => Promise<void>

CSS Shadow Parts

No CSS shadow parts available for this component.

CSS Custom Properties

NameDescription
--backgroundBackground color of the input boxes
--border-colorBorder color of the input boxes
--border-radiusBorder radius of the input boxes
--border-widthBorder width of the input boxes
--colorText color of the input
--heightHeight of input boxes
--highlight-color-focusedThe color of the highlight on the input when focused
--highlight-color-invalidThe color of the highlight on the input when invalid
--highlight-color-validThe color of the highlight on the input when valid
--margin-bottomBottom margin of the input group
--margin-endRight margin if direction is left-to-right, and left margin if direction is right-to-left of the input group
--margin-startLeft margin if direction is left-to-right, and right margin if direction is right-to-left of the input group
--margin-topTop margin of the input group
--min-widthMinimum width of input boxes
--padding-bottomBottom padding of the input group
--padding-endRight padding if direction is left-to-right, and left padding if direction is right-to-left of the input group
--padding-startLeft padding if direction is left-to-right, and right padding if direction is right-to-left of the input group
--padding-topTop padding of the input group
--separator-border-radiusBorder radius of the separator between boxes
--separator-colorColor of the separator between boxes
--separator-heightHeight of the separator between boxes
--separator-widthWidth of the separator between boxes
--widthWidth of input boxes

Slots

No slots available for this component.