OtpInput

pro

OtpInput collects short verification codes through a row of single-character fields.

Installation

Add this component with the NateUI CLI.

npx nateui@latest add OtpInput

Examples

Controlled Value

Enter a code.

Completion

Waiting for a complete code.

Alphanumeric Code

Custom Height

Disabled

API

PropDescriptionTypeDefault
valueControlled code value.string—
defaultValueInitial code for uncontrolled use.string''
onChangeCalled with the current code whenever a character changes.(value: string) => void—
onCompleteCalled when every code field contains a character.(value: string) => void—
lengthNumber of code fields.number6
codeTypeAllowed character set.OtpCodeType'numeric'
autoFocusFocus the first code field on mount.booleantrue
disabledPrevent code entry.booleanfalse
heightExplicit pixel height for each code field.number—
inputClassNameAdditional classes applied to each code field.string—
classNameAdditional classes applied to the code-field group.string—

Types

type OtpCodeType = 'numeric' | 'alphanumeric'