React One Time Password Input Component API

One Time Password Input API

Explore the API reference for the React One Time Password Input components and discover how to effectively utilize their props for customization.

COneTimePassword

jsx
import { COneTimePassword } from '@coreui/react-pro'
PropertyDefaultType
ariaLabel(index: number, total: number) => `Digit ${index + 1} of ${total}`((index: number, total: number) => string)

Function to generate aria-label for each input field. Receives current index (0-based) and total number of inputs.

autoSubmit-boolean

Automatically submit the form when all one time password fields are filled.

className-string

A string of all className you want applied to the React.js OTP component.

defaultValue-string, number

Initial value for uncontrolled React.js one time password input.

disabled-boolean

Disable all one time password (OTP) input fields.

feedback4.2.0+-ReactNode

Feedback for the current validationState — rendered only while the state is set, and styled after it. For the client-side mode, where the browser owns the state, use feedbackValid and feedbackInvalid instead.

feedbackInvalid4.2.0+-ReactNode

Feedback the stylesheet reveals while the control is invalid — always rendered, so it works with client-side validation, where the browser decides the state.

feedbackValid4.2.0+-ReactNode

Feedback the stylesheet reveals while the control is valid — always rendered, so it works with client-side validation, where the browser decides the state.

floatingClassName4.5.0+-string

A string of all className you want applied to the floating label wrapper.

floatingLabel4.2.0+-ReactNode

Provide a floating label for the component — the text rests inside the field and floats once it has focus or a value.

floatingLabelAlways6.0.0+-boolean

Keeps the floating label floated and the placeholder visible while the field is empty.

id-string

ID attribute for the value input.

invalidDeprecated 6.0.0-boolean

Mark the control invalid.

Use validationState="invalid" instead — invalid is ignored when validationState is set.

label4.2.0+-ReactNode

Add a caption for a component.

lineartrueboolean

Enforce sequential input (users must fill fields in order).

masked-boolean

Show input as password (masked characters).

name-string

Name of the value input the code is submitted under. Without it the code is not submitted with the form.

onChange-((value: string) => void)

Callback triggered when the React.js one time password (OTP) value changes.

onComplete-((value: string) => void)

Callback triggered when all React.js one time password (OTP) fields are filled.

onValidationStateChange6.0.0+-((validationState: ValidationState | undefined) => void)

Callback fired with undefined when the user changes the code, or the form is reset, while validationState (or invalid/valid) is set. A given state is a verdict on the code it was given for; clear it here to let the browser's own validation show again.

placeholder-string

Placeholder text for input fields. Single character applies to all fields, longer strings apply character-by-character.

required-boolean

Makes the code required: an empty or incomplete code blocks the submit.

size-'sm', 'lg'

Sets the visual size of the React.js one time password (OTP) input. Use 'sm' for small or 'lg' for large input fields.

text4.2.0+-ReactNode

Add helper text to the component.

tooltipFeedback4.2.0+-boolean

Display validation feedback in a styled tooltip.

typenumber'number', 'text'

Input validation type: 'number' for digits only, or 'text' for free text.

validDeprecated 6.0.0-boolean

Mark the control valid.

Use validationState="valid" instead — valid is ignored when validationState is set.

validationState6.0.0+-'valid', 'invalid', string

The validation state, rendered as the is-{state} class on the group; 'invalid' also sets aria-invalid on every slot and blocks the submit. Any custom state declared in the $form-validation-states Sass map is accepted. The user's next change of the code asks to drop it through onValidationStateChange.

value-string, number

Current value for controlled OTP input. When set, update it yourself from onChange, or the rendered code stays as it is.

COneTimePasswordGroup

jsx
import { COneTimePasswordGroup } from '@coreui/react-pro'
PropertyDefaultType
className-string

A string of all className you want applied to the component.

COneTimePasswordInput

jsx
import { COneTimePasswordInput } from '@coreui/react-pro'
PropertyDefaultType
className-string

A string of all className you want applied to the component.